Flutter, AppBar navigation with Persistent Bottom Navigation bar - android

I am using Persistent Bottom Nav Bar package and I want to Navigate to a desired page using a button on the AppBar, however the NavBar disappears if I do it like this. I understand this may be because they are apart of the same class (Working with the example project from Persistent Nav Bar git hub).
I have tried different ways of routing without luck.
How can I work around this so the drawer and the AppBar buttons would keep the Nav Bar?

You could try something like this:
Scaffold( appBar: AppBar(), body: PersistentTabView() );
solution from - https://github.com/BilalShahid13/PersistentBottomNavBar/issues/171

Related

How to navigate right between screens with bottomBar and others

Please, help me to understand how to do it right.
I have an app, which represent a screen with bottom bar with 4 tabs (1st layer). From this tabs we can enter other screens (2nd layer) without bottom bar. This organized very simple, Scaffold with bottom bar and navigation host inside it. To open screens above 1st layer without navigation bar I searched and found that I can just hide bottom bar and then open the screen above.
This is good, but on slow devices an ugly animation happen when 1)bottom bar is going down (user see the old screen without bottom bar) and 2) new screen appears.
This is not pleasant, but.. ok.
The second thing that I cannot stand is when in a 1-st layer screen I have a ModalBottomSheetLayout. When it hidden - it hides right behind bottom navigation bar and when I am going to new screen bottom navigation animated down and... here you are - the ModalBottomSheetLayout, and only then the second screen come to the place.
I wonder, may be I understand everything wrong and the new screens shouldn't be organized like this? How to set up navigation and scene like before compose we have a main fragment with bottom nav bar and open fragments on the top?
The example of the code I am talking about can be found for example in app nowinandroid, I think this is very common case.. As I see they also just hide bottom bar when needed..
#Composable fun NiaApp...

Flutter dynamic bottom navigation bar

In my Project i have 4 screens.
Home - Help Center - Search - Profile.
In Home page: My AppBar has leading and action buttons without title and transparent.
In Help Center My AppBar has leading doesnt have action buttons has a title and its a custom appbar.
In Search Screen : Using same appbar as help center screen but has action buttons and leading.
My Question is: As you can understand in my app i using few diffrent appbars. So how can i connect that bottomNavigationBar dynamicly ? Appbars isn't same thats why i cant use bottomNavigationBar for now.
So what can i do about it ? How can i make it dynamic ? Thanks for all responses!
What do you mean by connecting bottomNavigationBar?
I did not understand what your problem is completely, but if you want that bottom nav bar is common for your all pages you can use this approach:
//class variable
final _screens = [
const Page1(),
const Page2(),
const Page3(),
];
//your start page
return Scaffold(
resizeToAvoidBottomInset: false,
body: Stack(
children: [
_screens[_currentIndex],
//some code
],
),
);
And you can change _currentIndex by tapping your nav bar items. For more help you can share some code parts of your app and explanation.

Flutter Drawer gets closed automatically outside of it's click

I want to prevent my end drawer to be closed after clicking outside of it, I open my endDrawer with this line scaffoldKey.currentState.openEndDrawer so when I accidentally click outside of this drawer where you see gray drawerScrimColor it gets closed automatically as per its natural behavior, I do not want to do that what I see is only endDrawerEnableOpenDragGesture: false but this prevents my drawer not to be opened with DragGesture but my problem is different I do not want my drawer be closed automatically upon clicking outside of it please help me out your help will be appreciated thanks a lot in advance
I faced the exact same scenario in my app in which I wanted to disable the drawer closing when the outer translucent scrim is clicked.
This is the solution I used (still use):
return Scaffold(
...,
drawer: Container(
color: Colors.transparent,
child:
Row(children: const [SizedBox(width: 304, child: DrawerMenu())])),
...
);
The color of the Container has to be set to something, else it won't work. It is set to transparent as the Scaffold's default translucent scrimColor is enough.
The width is set to 304 as this is the default width of the Drawer as mentioned here.
The Row used here, is not over-engineering, it is used to prevent the child widget expanding to the screen width which is the default behavior of Scaffold's Drawer.
I use this instead of other solutions based on overriding the Gestures as it's simple and it doesn't affect Scrolling in/Dragging the Drawer.

How to hide android's bottom navigation bar in flutter

I'm really new in flutter and also in Android dev, but is it possible to hide the bottom navigation bar (see which item do i mean below) programmatically?
Try this:
SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.top]);
Document
For specifies the set of system overlays to have visible when the application
is running. you can use below static method:
SystemChrome.setEnabledSystemUIOverlays(List<SystemUiOverlay> overlays)
Examples :
1 - For Hide bottom navigation bar and Still Status bar visible
SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.top]);
2 - For Still bottom navigation visible bar and Hide Status bar
SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.bottom]);
3 - For hide both bottom Navigation and Status bar
SystemChrome.setEnabledSystemUIOverlays([]);
4 - For make both visible
SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.top, SystemUiOverlay.bottom]);
At the time of writing this answer all of the other posts here are outdated, using setEnabledSystemUIOverlays will give a deprecation message.
To hide the system navigation bar or status bar import:
import 'package:flutter/services.dart';
And use the service SystemChrome.setEnabledSystemUIMode
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky);
The function setEnabledSystemUIMode receives the SystemUiMode Enum which has the following options:
leanBack - Fullscreen display with status and navigation bars presentable by tapping anywhere on the display.
immersive - Fullscreen display with status and navigation bars presentable through a swipe gesture at the edges of the display.
immersiveSticky - Fullscreen display with status and navigation bars presentable temporarly through a swipe gesture at the edges of the display.
edgeToEdge - Fullscreen display with status and navigation elements rendered over the application.
manual - Declares manually configured [SystemUiOverlay]s. (look at the docs for more information)
Use SystemChrome.setEnabledSystemUIOverlays([]) to hide the status bar and the navigation bar.
I think you can use this
SystemChrome.setEnabledSystemUIMode(SystemUiMode.manual, overlays: [SystemUiOverlay.top]);
in your initState()
Currently this feature is bugged in flutter, you can see this issue here.
https://github.com/flutter/flutter/issues/62412
Normally you would need to do the following:
SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.top]);
This Approach is depreciated
SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.top]);
To show the status bar only
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky,overlays: [SystemUiOverlay.top]);
To show the system navigation bar only
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky,overlays: [SystemUiOverlay.bottom]);
To hide both
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky,
overlays: []);
It is better the put it before the runApp method like this
void main() {
WidgetsFlutterBinding.ensureInitialized();
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersiveSticky, overlays:[]).then(
(_) => runApp(MyApp()),
);
}

React Navigation transparent bar missing title and buttons on android

I'm building a React Native app with React Navigation 2.5.x. I have a transparent navigation bar. On iOS everything is fine, but on Android the title, back button and any barButton I put there is missing.
The navigation options is defined like this:
const navigationOptions = {
headerStyle: {
borderBottomWidth: 0,
},
headerTransparent: true,
headerTintColor: Colors.barTintColor,
};
If I try to inspect the view I get the header component when tapping, but on Android I get the scenes content view instead.
Previously I had the header style positioned absolutely and a transparent background color. I would like the bar to be transparent and visible above the rest of content screen. But positioning it absolutely, setting headerMode och headerTransparent all makes the headers disappear.
What am I doing wrong?

Categories

Resources