How to use navigation inside ModalBottomSheet in Flutter? - flutter

I want to show a Webview inside a ModalBottomSheet. The behavior I want is that the back button should navigate the webview till it can go back. I was able to achieve that using WillPopScope.
But this also disables the closing of ModalBottomSheet on tapping outside it in the grey area. How can I achieve both the behaviors?

Related

is this the right method instead using bottom bar navigation

I am new to Flutter. As I understand Bottom Bar Navigation is used for quick navigation between the top-level views of an app. but in my situation, I want to use like this which only button PAY can be clicked.
so is it okay if Im not using BottomBar instead i use as container and place it at bottom?
ya ,The best way is that you can create a container and the button and place it child of bottomNavigationBar so the flutter is automaticaly align it in bottom side
bottomNavigationBar: Container(child: yourcodeHere),

How to dismiss DraggableScrollableSheet in Flutter?

I try to make a pop up card when I press on a specific button and I use DraggableScrollableSheet because I want it starts minimized then the user can drag it up to maximize it.
so the question is there some way to dismiss this widget when the user press on the back screen or any other way to dismiss it?
I just call pop function inside the onTap callback function of the GestureDetector.
Navigator.pop(context);

In Flutter is there a way to check if the visible page has been presented modally

This is a common problem with iOS and is easily solved as all UIViewControllers have the property to check how they have been presented; whether modally or by being pushed onto a stack.
In Flutter we don't have view controllers, so we push new routes and one of the options is to use a fullScreenDialog. Your app bar will then have a close button and automatically pop when tapped.
But, if you want to dynamically adjust your Scaffold widgets based on whether they are presented in this way or not, there doesn't seem to be a way to detect that you are in a fullScreenDialog state (or modal). I have some pages that are part of the root tab navigation and therefore show a tab bar to switch between sections. I would like to reuse some of these pages but present them modally. In this case I want to remove the tab bar.
Is there any way to detect if a Navigator or Scaffold has been presented modally? Or do I just have to pass in a isModal bool?
I was thinking of perhaps a different solution based on your need and usecase.
It's respectable the you'd rather not repeat code just to get rid of an appBar when it's not needed.
Here's my suggestion, that would work with and take advantage of the framework rather than fight it.
Create your MultiPurposeSuperUsefulWidget, without a scaffold or appBar.
This widget can be shown easily without problems even needed with tabBar navigation.
The obstacle is wanting to use this in modal mode, you have the option to create this modal widget/screen template, that takes a final Widget widget constructor.
Customize this modal template in the way you like, and let's call it ModalTemplateScreen.
Finally, when you want your MultiPurposeSuperUsefulWidget to be displayed in modal style, navigate to ModalTemplateScreen(widget: MultiPurposeSuperUsefulWidget) and pass your reusable widget as an argument.
To set properties of your app bar based on modality you need to access the current Route and then check if the route was presented as a fullscreenDialog
isModal = (ModalRoute.of(context) as PageRoute).fullscreenDialog;

How can I make this custom app bar in flutter(android)?

I am trying to create a android tab bar like this image custom tab bar in flutter.
How can I make a tab bar like this?
There are so many examples for your questions you can check the links. Also appbar is a widget on the top of the screen and has buttons. You can create a buttons in the scaffold widget and put them top of the screen still same but easy to decorate and use.
Custom AppBar Flutter
Custom AppBar

How to pop bottom modal sheet when keyboard is hidden?

I want to pop my bottom modal sheet when my keyboard is hidden. But currently when I press back button keyboard gets hidden but bottom modal sheet remains opened.
I tried using package flutter_keyboard_visibility to detect if the keyboard is hidden and tried to pop the bottom navigation bar. But now when do that and press outside barrier to dismiss, there are two calls to Navigator.pop(context) method. One after hiding the keyboard and another built-in pop by the bottom modal sheet.
Can anyone help me find out how to achieve this?
Thanks.
I would do it the following way:
a) Return WillPopScope inside the Widget build method
b) As a callback for WillPopScope I will Navigator.pop(context)
You can also try the keyboard_visiblity plugin. This will provide you a callback easily.
Did you try using setState(() {}); ?
it will also helps for updating the state of screen