So I am completely new to flutter, and want create an app.
I found that you can define a theme for the entire app, so I want to give it a go.
Unfortunately though I don't seem to have any real control of it.
For example I can't seem to change the color of "Hello world". It just ends up gray.
If I change it in the style to something hardcoded ex Colors.amber then it works, but I would prefer to set it via the theme, which I assume is possible?
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(
seedColor: Colors.white10,
brightness: Brightness.dark,
),
textTheme: TextTheme(
titleLarge: GoogleFonts.inter(fontSize: 30, color: Colors.orange),
),
),
home: Scaffold(
body: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 32),
child: Column(
children: [
Text(
"Hello world",
style: Theme.of(context).textTheme.titleLarge!,
),
],
),
),
),
);
}
So that is what I have now. What am I not understanding about the colors? why isn't the text orange?
Theme.of(context)actually gets from parent context, currently it is within the same context level, 1. you can move the MaterialApp(ThemeData on parent, or wrap with a Builder widget which will provide separate context .home: Builder( builder: (BuildContext context) => Scaffold(