import 'package:flutter/material.dart';
void main() {
runApp(const MaterialApp(
debugShowCheckedModeBanner: false,home: MyApp(),
));
}
const colors = [
Colors.red,Colors.blueAccent,
Colors.yellowAccent,Colors.orangeAccent,
Colors.purpleAccent,Colors.pinkAccent,
Colors.indigoAccent,Colors.greenAccent,
Colors.cyanAccent
];
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
...List.generate(9,((index) =>
ColChild(color: colors[index], content: "Hello $index")))
],
));
}
}
class ColChild extends StatelessWidget {
final Color color;
final String content;
const ColChild({super.key,
required this.color, required this.content});
@override
Widget build(BuildContext context) {
return Container(
color: color,
height: 150.0,
child: Text(
content,
style: const TextStyle(fontWeight: FontWeight.bold),
),
);
}
}