I was following an old flutter tutorial in which backgroundColor was used. Here is what I wrote following the tutorial:
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'My app',
theme: ThemeData.dark().copyWith(
backgroundColor: backgroundColor,
),
home: const Text("My UI page"),
);
}
}
The myBackgroundColor is a const in another file consiting all the colors for the app. What should I write in theme to apply myBackgroundColor?
The flutter docs say backgroundColor is deprecated and use colorScheme.background instead. But when using colorScheme.background I get an error sayind undefined name 'colorScheme'.
As it states
'backgroundColor' is deprecated and shouldn't be used. Use colorScheme.background instead.
Try
theme: ThemeData.from(
colorScheme: const ColorScheme.dark(
background: Colors.black,
),
),
'background' is deprecated and shouldn't be used. Use surface instead. This feature was deprecated after v3.18.0-0.1.pre. Try replacing the use of the deprecated member with the replacement.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With