Last active
June 30, 2020 12:08
-
-
Save AyushBherwani1998/2ac3b760c0a949db88e597160410ad86 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter/material.dart'; | |
| final colorScheme = const ColorScheme.dark( | |
| primary: Colors.red, | |
| ); | |
| final colorSchemeLight = const ColorScheme.light( | |
| primary: Colors.red | |
| ); | |
| void main() => runApp(MaterialApp( | |
| // Replace colorScheme with colorSchemeLight to see proper out, the AppBar will respect ColorScheme.primary and it will | |
| // paint itself red. | |
| theme: ThemeData.from(colorScheme: colorScheme) , | |
| home: MyApp(), | |
| )); | |
| class MyApp extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) { | |
| return Scaffold( | |
| appBar: AppBar( | |
| title: Text('MyApp'), | |
| ), | |
| body: Center( | |
| child: Text('Hello'), | |
| ), | |
| ); | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Issue: flutter/flutter#48195
The issue basically describes that the way
ThemeData.fromignoreColorsScheme.primarywhen brightness is dark. In the current sample you can seeAppBaruses the color to paint which is inconsistent for bothBrightness.light&Brightness.darkwhenThemeData.fromis used. If you run the current example, theAppBarcolor should be red, but it stays black. If you use the ColorscolorSchemeLightwhich is the variable I have created, theAppBarrespects that which is not in the case ofBrightness.dark.Han's has already pointed out the underlaying issue.