| import 'package:flutter/material.dart'; |
| |
| class CounterPage extends StatefulWidget { |
| const CounterPage({super.key}); |
| |
| @override |
| State<CounterPage> createState() => _CounterPageState(); |
| } |
| |
| class _CounterPageState extends State<CounterPage> { |
| int _count = 0; |
| |
| @override |
| Widget build(BuildContext context) { |
| return Scaffold( |
| appBar: AppBar( |
| title: const Text('Counter'), |
| ), |
| body: Center( |
| child: Row( |
| mainAxisAlignment: MainAxisAlignment.center, |
| children: [ |
| Image.asset('assets/icon.png', width: 48, height: 48), |
| const SizedBox(width: 16), |
| Text( |
| '$_count', |
| style: const TextStyle(fontSize: 48), |
| ), |
| ], |
| ), |
| ), |
| floatingActionButton: FloatingActionButton( |
| onPressed: () { |
| setState(() { |
| _count++; |
| }); |
| print('Pressed $_count times'); |
| }, |
| child: const Icon(Icons.add), |
| ), |
| ); |
| } |
| } |