| 123456789101112131415161718192021222324252627282930313233 |
- import 'package:flutter/material.dart';
- class MyHomePage extends StatefulWidget {
- final String title;
- const MyHomePage({Key? key, required this.title}): super(key: key);
- @override
- _MyHomeState createState() => _MyHomeState();
- }
- class _MyHomeState extends State<MyHomePage> {
- int _counter = 0;
- void _incrementCounter() {
- setState(() {
- _counter++;
- });
- }
- @override
- Widget build(BuildContext context) {
- // TODO: implement build
- return Scaffold(
- appBar: AppBar(title: Text(widget.title)),
- body: Text('$_counter'),
- floatingActionButton: FloatingActionButton(
- onPressed: _incrementCounter,
- tooltip: 'Increment',
- child: Icon(Icons.add),
- ),
- );
- }
- }
|