https://ibb.co/fdVTDHV
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(),
home: Scaffold(
appBar: AppBar(
title: Text('Academia'),
centerTitle: true,
),
body: ListView(
children: [Treinos(50)],
),
),
);
}
}
class Treinos extends StatefulWidget {
int peso;
Treinos(this.peso, {super.key});
@override
State<Treinos> createState() => _TreinosState();
}
class _TreinosState extends State<Treinos> {
@override
Widget build(BuildContext context) {
return Container(
child: Stack(
children: [
Container(
height: 300,
color: Colors.green,
),
Column(
children: [
Container(
color: Colors.white54,
height: 150,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [Text('Teste')],
),
),
Container(
color: Colors.black,
height: 50,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Container(
height: 30,
width: 30,
alignment: Alignment.center,
child: ElevatedButton(
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all(Colors.red)),
onPressed: () {
setState(() {
(widget.peso > 0)
? widget.peso--
: widget.peso = 0;
});
},
child: Column(
children: [Icon(Icons.arrow_drop_down)],
),
)),
Text(
'Peso: ${widget.peso}',
style: TextStyle(fontSize: 20, color: Colors.white),
),
],
),
),
Container(
color: Colors.blue,
height: 100,
)
],
)
],
),
);
}
}