You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Should the modal barrier of an Alert also change the color of the status bar? #24969
Then create an AlertDialog that shows up on an event
newAlertDialog(
title:newText("Something went wrong!"),
content:newText("Be sure you are connected to the Device"),
actions: [
newFlatButton(
child:constText("Ok"),
onPressed: () {
Navigator.pop(context);
_alertShown =0;
}),
])
When the AlertDialog is fired up the custom status bar color stays bright and its opacity is not affected
This is expected but the correct approach is not quite documented yet. For reference here is a working implementation that uses the AnnotatedRegion widget:
The problem with using setSystemUIOverlayStyle directly is that it competes with every other call, including those sent via the appBar. Whereas the AnnotatedRegion determines the correct style to use based on hit testing, so you can more easily control which style is used
I turned #24893 into the doc bug regarding AnnotatedRegion.
For this bug, the open question is should the modal barrier of an Alert also change the color of the status bar? We should check some native apps to see what they do.
As this is linked to #49941, this is my solution for bottomsheet usecase.
Though I believe this is just temporary until fixed in offical release.
You would have to handle dialog color, margin from the statusbar by yourself though.
Do note that in other screens, I use systemOverlayStyle parameter in AppBar to change statusbar's color.
classBottomSheetUtil {
constBottomSheetUtil();
Future<T?> show<T>(
BuildContext context, {
WidgetBuilder? contentBuilder,
}) {
returnshowModalBottomSheet<T>(
context: context,
isScrollControlled:true,
useRootNavigator:true,
backgroundColor:Colors.transparent, // we will need to set the background color by ourself in `_BottomSheetWidget`
builder: (context) =>const_BottomSheetWidget(),
);
}
}
class_BottomSheetWidgetextendsStatelessWidget {
const_BottomSheetWidget();
@overrideWidgetbuild(BuildContext context) {
returnconstAnnotatedRegion<SystemUiOverlayStyle>(
value:SystemUiOverlayStyle(
statusBarColor:Colors.transparent, // set statusbar color to transparent, this will cause overlay effect
),
sized:false, // set this too
child:Placeholder(), // handle the margin, backgroundColor, padding by yourself
);
}
}
But this workaround doesn't work exactly, since making the status bar transparent is not the same as it staying it's current color but being darkened by flutter like the default behaviour.
Activity
zoechi commentedon Dec 5, 2018
Please add the output of
flutter doctor -v.sdivakarrajesh commentedon Dec 5, 2018
Okay.. here is some sample code that you can try out to see the bug
main.dartAnd here is what I get when I run flutter doctor - v
HansMuller commentedon Dec 5, 2018
@jonahwilliams - is this expected Android behavior?
jonahwilliams commentedon Dec 5, 2018
This is expected but the correct approach is not quite documented yet. For reference here is a working implementation that uses the AnnotatedRegion widget:
https://gist.github.com/jonahwilliams/a0c278572f9bdce77104a47e39b4a72a
The problem with using
setSystemUIOverlayStyledirectly is that it competes with every other call, including those sent via the appBar. Whereas the AnnotatedRegion determines the correct style to use based on hit testing, so you can more easily control which style is usedjonahwilliams commentedon Dec 5, 2018
I think I misunderstood the issue, I don't think the status bar should be obscured?
goderbauer commentedon Jan 4, 2019
I turned #24893 into the doc bug regarding AnnotatedRegion.
For this bug, the open question is should the modal barrier of an Alert also change the color of the status bar? We should check some native apps to see what they do.
27 remaining items
armandojimenez commentedon May 11, 2023
Any updates on this?
Andrewcpu commentedon May 18, 2023
To answer the title, imo, yes. The modal barrier of an alert should change both the status bar and the navigation bar.
angelru commentedon Nov 10, 2023
any solution?
SilentCatD commentedon Dec 16, 2023
As this is linked to #49941, this is my solution for bottomsheet usecase.
Though I believe this is just temporary until fixed in offical release.
You would have to handle dialog color, margin from the statusbar by yourself though.
Do note that in other screens, I use
systemOverlayStyleparameter inAppBarto change statusbar's color.SilentCatD commentedon Dec 16, 2023
And this is workaround for dialog usecase
Do note that in other screens, I use
systemOverlayStyleparameter inAppBarto change statusbar's color.RCVZ commentedon Aug 17, 2024
@darshankawar do you have an update on this issue?
Jonny1987 commentedon Oct 30, 2024
The workarounds above do not work when useSafeArea is true in the showModalBottomSheet.
I had to do the following to imitate useSafeArea by settings the maxHeight of the bottom sheet:
MediaQuery.viewPaddingOf(context).topin state at the start of the appJonny1987 commentedon Oct 30, 2024
But this workaround doesn't work exactly, since making the status bar transparent is not the same as it staying it's current color but being darkened by flutter like the default behaviour.
ondikumana commentedon Dec 3, 2024