AppBar Leading Customizable? - flutter

i need your help because i am customizing my AppBar in flutter and i'd like to know if there is a way to decide what to show on the leading part: in my homepage i'd like to see a logo, but if i navigate to other screens i'd like to see the back button. So my question is: is there a way to write an AppBar class where, maybe with a statement, the device show the logo or the back button(seeing the navigation history)?
I hope you understand and thanks.

Sure, that's very simple:
In your home screen, pass your logo (can be any Widget) to the AppBar's leading argument.
On the other screens, pass nothing and set automaticallyImplyLeading: true - the AppBar will create a back button automatically.
Alternatively, if you only use one AppBar for the whole app, use this snippet:
AppBar(
leading: ModalRoute.of(context).settings.name == "MY_HOME_SCREEN_ROUTE" ? MyLogoWidget : null,
automaticallyImplyLeading: true,
...
);

I suggest you read this article to have different types of appbar:
https://medium.com/flutter-community/flutter-increase-the-power-of-your-appbar-sliverappbar-c4f67c4e076f

Related

Flutter: How to show content behind bottomNavigationBar

I have an app that has a bottomNavigationBar() wrapped in a clipRRect() but the content doesn't show behind it. The same behaviour also happens with transparent SliverAppBar()s in NestedScrollView()s. How can I achieve this?
Edit: Here is an example of the SliverAppBar() problem. The shadow is being hidden by the app bar.
you can try this:
Scaffold(
extendBody: true,
extendBodyBehindAppBar: true,
and give a little padding to the top and bottom of you body content for overlapping at the very top and bottom.

How to remove arrow in new page in flutter?

When I use a pushNamedRoute(NewScreen.routeName)then automatically added the back arrow button how to delete that?
Please add automaticallyImplyLeading: false, into your Scaffold's Appbar
You can do it like Balaji Ramadoss mention. But if you don't want the user to be able to navigate to the last page, then rather use pushReplacementNamed(context, routename)

How to create a custom back press button?

I am new to flutter and curious if we can create a custom back press button, not the one in appbar.
Just like a normal button that takes back to previous screen.
Here's how you so that:
Create a raw material button
Add the on press method to decide which screen it goes to.
In you main.dart, under the routes method, import the screen you want to push the current screen back to and then call it something.
Inside your onPress() method, you can call Navigator.pushNamed(context, routeName).
Now you can customise this raw material button as much as you want. Here are some of the main properties you can set:
textStyle
fillColor
elevation
padding
constraints
shape
child
Now give a name to this custom button you have created by extracting it into a widget.
Call the widget inside your code! If you want it to be aligned at the top left, which is usually where you find it:
Align(
alignment: Alignment.topLeft,
child: CustomButton()
),
Enjoy! PS: If you need any help, feel free to ask me and I will assist you to my best abilities!

How to make the keyboard go above my content?

Do you know how can I make my keyboard go above all the content?
Because I can see that flutter thinks that my keyboard is like a container which needs some space.
The resizeToAvoidBottomInset property is use to specify the behavior for this case.
Just set it to false to make the keyboard go above your content:
Scaffold(
resizeToAvoidBottomInset: false,
...
)

Remove or modify navigation drawer overlay shadow in Flutter

I created a Scaffold widget with appBar and drawer.
As I open the drawer, there is a shadow over the Scaffold's body widget. I'd like to either remove the shadow, make it not so "strong" or change the shade slightly.
I checked the docs and I didn't find any way to achieve this through public API.
Is there any way to remove the drawer menu's "drop shadow" on the body?
The elevation option is something different, even if I set it to 0, the overlay shadow on top of the body is still present.
This issue's description's screenshots might help clarify what I want.
If you want to get rid of the shadow over the Scaffold body then you have to change the Scaffold's drawerScrimColor's value to Colors.transparent.
Have you tried setting the drawer's elevation to elevation: 0.0?
check this
drawerTheme:
DrawerThemeData(scrimColor: Colors.transparent, elevation: 0.5),