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

toggleFullScreenMode() gives error FlutterError (Navigator operation requested with a context that does not include a Navigator #150

Closed
jimmyff opened this issue Feb 19, 2020 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@jimmyff
Copy link

jimmyff commented Feb 19, 2020

When I attempt to make the video full screen I get the following error:

FlutterError (Navigator operation requested with a context that does not include a Navigator.
The context used to push or pop routes from the Navigator must be that of a widget that is a descendant of a Navigator widget.)

I'm instegating this from a button using

onPressed: () => _controller.toggleFullScreenMode();
@jimmyff jimmyff added the bug Something isn't working label Feb 19, 2020
@jimmyff
Copy link
Author

jimmyff commented Feb 19, 2020

I have looked in to this problem. This is the most useful explanation I've found:
https://stackoverflow.com/questions/44004451/navigator-operation-requested-with-a-context-that-does-not-include-a-navigator

I am utilising the builder parameter of MaterialApp which says in the documentation Material specific features such as [showDialog] and [showMenu], and widgets such as [Tooltip], [PopupMenuButton], also require a [Navigator] to properly function. -so I do not understand why this isnt working?

I've also attempted to the YouTubePlayer widget in a builder however that didnt work.

This is my Material App:

    return new StoreProvider<AppState>(
        store: widget.store,
        child: MaterialApp(
          title: 'Media Flutter App',
          builder: (context, child) {
            return StoreConnector<AppState, MediaPanelViewModel>(
                converter: (store) => MediaPanelViewModel.fromStore(store),
                builder: (context, viewModel) {
                  return Scaffold(
                    drawer: Drawer(),
                    bottomNavigationBar: viewModel.currentlyPlaying == null
                        ? null
                        : MediaPanel(),
                    body: child,
                  );
                });
          },
          initialRoute: HomeRoute,
          onGenerateRoute: generateRoute,
        ));

MediaPanel is where I utilise YoutubePlayer.

Any ideas how I can fix it? I've looked through your code to see if I can find where it needs to utilise the Navigator but cant find it.

@sarbagyastha
Copy link
Owner

Cloud you please provide a reproducible example ?

@jimmyff
Copy link
Author

jimmyff commented Feb 25, 2020

yep, leave it with me

@jimmyff
Copy link
Author

jimmyff commented Feb 25, 2020

Hi @sarbagyastha, I've created an little project to highlight the issue:
bug.zip

To reproduce the full screen error:

  • Tap 'play video 1'
  • Tap full screen icon on the media bar at the bottom

Aside: This project also demonstrates a second issue, if you click on the playing video thumbnail I wanted to open it bigger at the bottom however the youtube player seems to break, I'm not sure what I'm doing wrong - maybe the webview is getting recreated. It would be nice to resolve this issue too but the full screen video issue is my main priority.

Any help getting the full screen working would be massively appreciated.

Thanks very much,
Jimmy

@jimmyff
Copy link
Author

jimmyff commented Feb 28, 2020

Hey @sarbagyastha I think having the option of passing in a global navigator key would fix the fullscreen issue?

https://stackoverflow.com/questions/52962112/how-to-navigate-without-context-in-flutter-app/53397266#53397266

brianegan/flutter_redux#5 (comment)

What do you think?

@jimmyff
Copy link
Author

jimmyff commented Mar 2, 2020

Hey @sarbagyastha did you manage to consider my suggestion for adding a navigator key parameter? I can implement it and send a PR if you don't have chance as this blocking me launching my app.

I would just make sure that wherever you are utilising Navigator it would use the key if provided. place such as here:

@jimmyff
Copy link
Author

jimmyff commented Mar 4, 2020

Created a PR that fixes this issue. Could you have a look?

#160

Thanks

@sarbagyastha
Copy link
Owner

Should fix with v7.0.0. Feel free to reopen if the issue persists.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants