Text Color
Part of the Your First App section of Coddy's Flutter journey. Lesson 9 of 32.
The color: of a TextStyle sets the color of the letters. Flutter has a ready list of colors called Colors:
Text(
'Go',
style: TextStyle(color: Colors.green),
)Type Colors. and the name: Colors.red, Colors.blue, Colors.orange, Colors.purple and many more. Some have a lighter twin with Accent on the end, like Colors.redAccent. That is a different color.
Challenge
EasyMake Stop red: add color: Colors.red to its TextStyle.
Try it yourself
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: Text('Stop', style: TextStyle(fontSize: 48)),
),
),
);
}
}
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Your First App
Practice on your own: Online Flutter compiler