xxxxxxxxxx
---- Using style property (backgroundColor)
Text(
'Some text...',
style: TextStyle(backgroundColor: Colors.blue),
)
---- Using style property (background)
Text(
'Some text...',
style: TextStyle(background: Paint()..color = Colors.blue),
)
---- Using a DecoratedBox
const DecoratedBox(
decoration: const BoxDecoration(color: Colors.blue),
child: const Text('Some text...'),
);
xxxxxxxxxx
new Text(
'Welcome to Flutter Tutorial.',
style: TextStyle(
color: Colors.blue,
),
)
xxxxxxxxxx
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: _title,
theme: ThemeData(
scaffoldBackgroundColor: Colors.green, // Set default BackgroundColor
textTheme: Theme.of(context).textTheme.apply( // Set default Text() color; Use: apply()
bodyColor: Colors.indigo,
displayColor: Colors.indigo,
),
),
color: Colors.red,
home: const HomeScreen(),
);
}
xxxxxxxxxx
Text(
errMessage,
style: const TextStyle(
color: Colors.red,
fontSize: 12,
fontWeight: FontWeight.w900,
),
),