Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
class MyHomePage extends StatefulWidget {
const MyHomePage({Key key}) : super(key: key);
_MyHomePageState createState() => _MyHomePageState();
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() => setState(() => _counter++);
Widget build(BuildContext context) {
final translations = ExampleLocalizations.of(context);
return Scaffold(
appBar: AppBar(
title: Text(translations.homePageTitle),
body: Center(
child: Text(translations.homePageCenterText(_counter)),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: translations.incrementTooltip,
child: Icon(Icons.add),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment