Issue
I have this:
Widget build(BuildContext context) {
return MaterialApp(
title: 'AnApp',
theme: ThemeData(
primarySwatch: Colors.blueGrey,
),
home: MainWidget()
);
}
}
So I have set primarySwatch color to blueGrey.
How can I access this color inside the MainWidget class?
I want to set a background the same as the AppBar color.
Solution
I'm not sure if there exist a way to use primarySwatch inside widget like that but if you are looking for AppBar color, it is actually the primaryColor and you can get it using
Color color = Theme.of(context).primaryColor;
Answered By - CopsOnRoad
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.