abraham / birb

WIP: Instagram for birds built in Flutter
https://bendyworks.com/blog/a-month-of-flutter
MIT License
95 stars 19 forks source link

Apply AnnotatedRegion that fixes #51 #69

Closed Miguel-Herrero closed 5 years ago

Miguel-Herrero commented 5 years ago

TL;TR: Prevent Google Sign In to change the SystemUiOverlayStyle that causes #51

It seems that the SystemUiOverlayStyle applied in main() is changed by Google Sign In modal when “Sign in with Google” button is tapped. Then, home_page.dart is redrawn and the AppBar inherits last used value (Google's dark style, instead of theme.dart's light style). To fix it, home_page.dart has to use theme.dart's SystemUiOverlayStyle.

From this Stack Overflow answer:

AppBar internally creates an AnnotatedRegion<SystemUiOverlayStyle> widget that is processed by Flutter's native UI bindings. It makes the status bar either dark or bright. On screens without an AppBar, you can use AnnotatedRegion<SystemUiOverlayStyle> to set the color of the status bar.

And from this other:

However if you have multiple widgets which set this value, or use the material AppBar or cupertino NavBar your value may be overwritten by them. Instead you could use the new AnnotatedRegion API to tell flutter to automatically switch to this style anytime certain widgets are visible.

BEFORE AFTER
abraham commented 5 years ago

This is fantastic! Thank you so much. Please add one test expectation and I'll get it merged.