Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interference with Navigator on Flutter Web #1

Open
Mateis opened this issue Jun 6, 2021 · 1 comment
Open

Interference with Navigator on Flutter Web #1

Mateis opened this issue Jun 6, 2021 · 1 comment

Comments

@Mateis
Copy link

Mateis commented Jun 6, 2021

This code used to work:

               child: RaisedButton(
                onPressed: () {
                  // Validate returns true if the form is valid, or false
                  // otherwise.
                  if (_formKey.currentState.validate()) {
                      
                    print("the search query is " + myController.text);

                    // Send data for tracking to Google Tag
                    gtm.push({'searchTerm': myController.text});
                    gtm.pushEvent('button1-click');
                    gtm.pushEvent('button2-click', data: {'value': myController.text});

                    // Navigate to the results screen.
                    Navigator.of(context).push(MaterialPageRoute(builder: (_) => SearchResults(myController.text)));

                  }
                },

Now it throws an error when the button is pressed:

════════ Exception caught by gesture ═══════════════════════════════════════════
The following JSNoSuchMethodError was thrown while handling a gesture:
TypeError: Cannot read property 'push' of undefined

When the exception was thrown, this was the stack
packages/google_tag_manager/src/google_tag_manager_base.dart 11:3                                                      push
packages/nationaalarchiefinkleur/components/search_form.dart 65:21                                                     <fn>
packages/flutter/src/material/ink_well.dart 989:21                                                                     [_handleTap]
packages/flutter/src/gestures/recognizer.dart 182:24                                                                   invokeCallback
packages/flutter/src/gestures/tap.dart 607:48                                                                          handleTapUp
...
Handler: "onTap"

I made no changes to the code. I simply build my web app again (using a later version of flutter; 1.25.0-8.1-pre, stable channel)

When I comment out the gtm code, Navigator works as expected.

To solve i tried to upgrade gtm package from 0.0.3 -> 0.1.0. It did not help.

@Hamza3620
Copy link

Hi @Mateis,

Is there a solution to this problem? I see this thread was created in 2021 and there is no response from the publisher of this package.
OR is there any other package available to handle GTM on Flutter Web?

Your response will be appreciated.

Thanks,
Hamza

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants