![]( )
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,
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.green,
),
home: Scaffold(
appBar: AppBar(
title: Text('Flutter: Primeiro Passos'),
),
body: ListView(
children: [
Quadrados(
cor1: Colors.amber,
cor2: Colors.green,
cor3: Colors.grey,
),
Quadrados(
cor1: Colors.blue,
cor2: Colors.pink,
cor3: Colors.lightGreen,
),
Quadrados(
cor1: Colors.orangeAccent,
cor2: Colors.blueGrey,
cor3: Colors.redAccent,
)
],
),
floatingActionButton: FloatingActionButton(
onPressed: () {},
),
),
);
}
}
class Quadrados extends StatelessWidget {
final Color cor1;
final Color cor2;
final Color cor3;
const Quadrados({required this.cor1, required this.cor2, required this.cor3, super.key});
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(8.0),
child: Row(
children: [
Quadrados2(cor1),
Quadrados2(cor2),
Quadrados2(cor3),
],
),
);
}
}
class Quadrados2 extends StatelessWidget {
final Color cor;
const Quadrados2(this.cor, {super.key});
@override
Widget build(BuildContext context) {
return Container(
width: 80,
height: 120,
color: cor,
);
}
}