import 'package:flutter/material.dart'; class CalculatorPage extends StatefulWidget { CalculatorPage({Key? key}) : super(key: key); final String title = 'BMI Calculator'; @override _CalculatorPageState createState() => _CalculatorPageState(); } class _CalculatorPageState extends State { int _counter = 0; void _incrementCounter() { setState(() { _counter++; }); } @override Widget build(BuildContext context) => Scaffold( appBar: AppBar( title: Text(widget.title), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text( 'You have pushed the button this many times:', ), Text( '$_counter', style: Theme.of(context).textTheme.headline4, ), ], ), ), floatingActionButton: FloatingActionButton( onPressed: _incrementCounter, tooltip: 'Increment', child: Icon(Icons.add), ), ); }