import 'package:flutter/material.dart'; class MyStatefulWidget extends StatefulWidget { const MyStatefulWidget({super.key}); @override State<MyStatefulWidget> createState() => _MyStatefulWidgetState(); } class _MyStatefulWidgetState extends State<MyStatefulWidget> { int count = 0; @override Widget build(BuildContext context) { return Scaffold( body: Center( child: Text("$count"), ), floatingActionButton: FloatingActionButton(onPressed: (){ setState(() { count++; }); }, child: const Icon(Icons.add),), ); } }