New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
primarySwatch: Colors.white => type 'Color' is not a subtype of type 'MaterialColor' #23239
Comments
#15658 (comment) should help |
Does this mean I can't chose my primary swatch to be white or black? |
As the comment says. White or black is not a swatch. |
Please consider asking support questions in one of the other channels listed at http://flutter.io/support . Feel free to add more comments and I try to help if I can but I think StackOverflow would be the right place for this question. GitHub issues are for bug reports and feature requests. |
Right. So using the Panache aka Flutterial theme browser, it actually has a white / black option. And that option looks surprisingly good - at least for white anyway. So I did some digging to find out why and how it works, and I can answer the why not, and how to, below. The Flutterial app makes a new MaterialColor widget, and everything is set to white: const MaterialColor white = const MaterialColor(
0xFFFFFFFF,
const <int, Color>{
50: const Color(0xFFFFFFFF),
100: const Color(0xFFFFFFFF),
200: const Color(0xFFFFFFFF),
300: const Color(0xFFFFFFFF),
400: const Color(0xFFFFFFFF),
500: const Color(0xFFFFFFFF),
600: const Color(0xFFFFFFFF),
700: const Color(0xFFFFFFFF),
800: const Color(0xFFFFFFFF),
900: const Color(0xFFFFFFFF),
},
); So, you would expect everything to be white right? No, its actually quite a nice, toned back design. To test it out yourself, copy and paste that code into your class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'MyApp',
theme: ThemeData(
primarySwatch: white, Of course, having a swatch with every colour the same seems logically stupid, and so that is why its not included. |
Thank You |
Thanks for the info guys. I used this and it's great for what I want. One thing I would like to ask is (and keep in mind that I am new to Flutter/Dart (or programming in general)): The problem is that I don't have the nous to turn this into something that can be used globally. Q: Anyone able to enlighten me? Cheers and thanks in advance, |
Thanks! Also, to make it more extensible, reuse the same variable might be a good idea:
|
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
When defining my ThemeData as follows the code runs perfectly:
(in file:///home/tamer/AndroidStudioProjects/flutter_app/lib/main.dart):
Now I'm trying to make my appbar color white. However, when I replace
primarySwatch: Colors.pink
withprimarySwatch: Colors.white
the code throws the following:The text was updated successfully, but these errors were encountered: