import 'package:flutter/material.dart';
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
const double squareSize = 100;
return MaterialApp(
title: 'Flutter Demo',
color: Colors.blue,
home: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
MyAppRow(
squareSize: squareSize,
color1: Colors.red,
color2: Colors.amber,
color3: Colors.yellow)
.row(),
MyAppRow(
squareSize: squareSize,
color1: Colors.green,
color2: Colors.cyan,
color3: Colors.blue)
.row(),
MyAppRow(
squareSize: squareSize,
color1: Colors.purple,
color2: Colors.pink,
color3: Colors.white)
.row(),
],
),
);
}
}
class MyAppRow extends Row {
MyAppRow({
required this.squareSize,
required this.color1,
required this.color2,
required this.color3,
});
final double squareSize;
final Color color1;
final Color color2;
final Color color3;
Row row() {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Container(
width: squareSize,
height: squareSize,
color: color1,
),
Container(
width: squareSize,
height: squareSize,
color: color2,
),
Container(
width: squareSize,
height: squareSize,
color: color3,
),
],
);
}
}