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),),
);
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter