Skip to content

Instantly share code, notes, and snippets.

@AyushBherwani1998
Last active June 30, 2020 12:08
Show Gist options
  • Select an option

  • Save AyushBherwani1998/2ac3b760c0a949db88e597160410ad86 to your computer and use it in GitHub Desktop.

Select an option

Save AyushBherwani1998/2ac3b760c0a949db88e597160410ad86 to your computer and use it in GitHub Desktop.
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'),
),
);
}
}
@AyushBherwani1998
Copy link
Author

AyushBherwani1998 commented Jun 30, 2020

Issue: flutter/flutter#48195

The issue basically describes that the way ThemeData.from ignore ColorsScheme.primary when brightness is dark. In the current sample you can see AppBar uses the color to paint which is inconsistent for both Brightness.light & Brightness.dark when ThemeData.from is used. If you run the current example, the AppBar color should be red, but it stays black. If you use the Colors colorSchemeLight which is the variable I have created, the AppBar respects that which is not in the case of Brightness.dark.

Han's has already pointed out the underlaying issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment