Boa tarde, pessoal.
Estou com uma dúvida. Para não ficar repetindo o tamanho do quadrado colorido (height e width), implementei que o tamanho é passado via parâmetros através da classe MyApp. Essa é uma boa prática para se adotar?
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp(height: 100, width: 100));
}
class MyApp extends StatelessWidget {
final double height;
final double width;
const MyApp({super.key, required this.height, required this.width});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: Container(
color: Colors.black,
child: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Container(color: Colors.red, height: height, width: width,),
Container(color: Colors.orange, height: height, width: width,),
Container(color: Colors.yellow, height: height, width: width,),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Container(color: Colors.green, height: height, width: width,),
Container(color: Colors.cyan, height: height, width: width,),
Container(color: Colors.blue, height: height, width: width,),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Container(color: Colors.purple, height: height, width: width,),
Container(color: Colors.pink, height: height, width: width,),
Container(color: Colors.white, height: height, width: width,),
],
)
],
),
),
);
}
}