Move endDrawer above bottomNavigationBar in Flutter - flutter

We have a endDrawer that is displaying behind the bottomNavigationBar. We want it to display over the navigation bar.
We may need a refactor but for now, we have a main Scaffold like so:
return Scaffold(
key: shellKey,
drawer: const MainDrawer(),
body: child,
extendBody: true,
bottomNavigationBar: const ExpandingBottomDrawer(),
);
The router pushes the child to this Scaffold via
ShellRoute(builder: (context, state, child) => AppLayout(child: child),...)
The children are also Scaffolds that have independent endDrawers. In the children, I am triggering opening the endDrawer via _key.currentState!.openEndDrawer(),.
The issue is the endDrawer is visibly behind the bottomNavigationBar. I understand this can be fixed if the endDrawer was on the main Scaffold, but the app is not set up that way and it would be a huge refactor. Is this possible without a refactor?
Thank you!!

You can use another Scaffold widget.
return Scaffold(
drawer: const Drawer(),
bottomNavigationBar: Container(
child: Text("Bottom navBar"),
),
body: Scaffold(
appBar: AppBar(),
drawer: const Drawer(),
),
);
There might be a better way of handling this.

Related

How i can hide and show app bar with animation flutter

Here is my code
return Scaffold(
body: SafeArea(
appBar:getIsShowAppBar(layoutProvider.currentIndex,
realEstatesProvider) ? AppBar (),
child: IndexedStack(
children: layoutProvider.screens,
index: layoutProvider.currentIndex),
),
bottomNavigationBar: BottomNavigationBar(), );
If you want to show an app bar and hide it when you want you would want to use the SliverAppBar widget witch allows you to make an app bar of your choice and allows to dissapear it when scrolling and other options with animations. https://api.flutter.dev/flutter/material/SliverAppBar-class.html

How do I make bottomsheet swipe up from anywhere in scaffold flutter

I am trying to make a launcher in flutter, however I cannot figure out how to make a drawer that can be swiped up from the home screen, like in other launchers like nova or poco or many others. I understand that the app drawer closely matches a bottom sheet, but bottom sheets in flutter need to be first tapped on them and then dragged. How do I drag a widget up from anywhere on the scaffold?
To obtain the functionality you're looking for use this package: flutter slider
Example:
with code as simple as this you can obtain the slideup bottom sheet like functionality:
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("SlidingUpPanelExample"),
),
body: SlidingUpPanel(
panel: Center(
child: Text("This is the sliding Widget"),
),
body: Center(
child: Text("This is the Widget behind the sliding panel"),
),
),
);
}

How to push a widget outside of context?

My current screenstructure looks like this:
Scaffold(
body: Stack(
children: [
_buildOffstageNavigator(FeedScreen()),
_buildOffstageNavigator(Screen2()),
_buildOffstageNavigator(Screen3()),
],
),
bottomNavigationBar: buildBottomNavigationBar(),
)
the BottomNavigationBar is just a regular bar.
Each of those screens are wrapped with a OffStage() widget like this:
Widget _buildOffstageNavigator(Widget screenToBuild) {
return Offstage(
offstage: currentPage != screenToBuild,
child: TabNavigator(
navigatorKey: _navigatorKeys[screenToBuild],
screenToBuild: screenToBuild,
),
);
}
My intention with this was to ensure a BottomNavigationBar at all times.
However, there is one widget, that I want to push from FeedScreen() that I don't want the NavigationBar on, but the context makes it hard to hide this NavigationBar
This is the structure of the FeedScreen()
Scaffold(
appBar: buildAppBar(),
body: SingleChildScrollView(
key: PageStorageKey<String>("Feed"),
controller: _feedSC,
child: Column(
children: [
buildStoriesListView(),
buildPostsListView(posts)
],
),
),
)
So my question is: Is there a way to push this Widget "on top" of the stack and kind of ignore the context or do I just have to hide the bar in this case? How would you do that?
Thanks
You can wrap you Scaffold with a Navigator and use Navigator.of(context, rootNavigator: true).push(PageRouteBuilder(pageBuilder: (context, _, __) => Foo())); to push the Foo widget on top of everything.

How do I align these widgets?

I am making a practice app in flutter and stuck on this:
How can i align widgets such that;
1. An icon stays at extreme left of appbar
2. Text widget stays in middle.
3. button stays at extreme right of appbar.
here is the image for what i am talking about
use actions property in appbar and then as a child use a row. in that row you can use MainAxisAlignment.spaceBetween or MainAxisAlignment.spaceAround for arranging items.
You can do it using AppBar widget.
Note: If you want to implement drawer then use drawer property.
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Title"),
centerTitle: true,
leading: Icon(Icons.menu),
actions: [Icon(Icons.comment)],
),
body: Container(),
);
}
AppBar(title:Text("Your Text),leading:Icon(Icons.menu),actions:[Icon(Icons.favourite)])
Try this code

How to add a drawer to SilverAppBar in flutter?

I have used SilverAppBar but don't know how to add a drawer to it. I just want an app bar with a drawer that hides on scrolling
Note that the Scaffold takes care of all of the major behavior associated with Material design.
If you add the drawer field to your Scaffold, it will automatically add a hamburger menu icon to the left hand side of your SilverAppBar in flutter.
Code:
#override
Widget build(BuildContext context) {
return Scaffold(
body: CustomScrollView(
slivers: <Widget>[
SliverAppBar(
title: Text('Drawer - Sliver AppBar'),
)],
),
drawer: Drawer(
child: Column(
children: <Widget>[
DrawerHeader(
child: Text(' I am Drawer'),
curve: SawTooth(12),
),
],
),
),
);
}