Skip to content

Instantly share code, notes, and snippets.

@mono0926
Last active March 28, 2023 07:52
Show Gist options
  • Save mono0926/72ed9936eee15126cc170f5282ab0cf7 to your computer and use it in GitHub Desktop.
Save mono0926/72ed9936eee15126cc170f5282ab0cf7 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: 'Flutter Demo',
home: HomePage(),
);
}
}
class HomePage extends StatefulWidget {
const HomePage({super.key});
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter += 1000;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Flutter Demo Home Page'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'You have pushed the button this many times:',
),
TweenAnimationBuilder(
tween: IntTween(begin: 0, end: _counter),
duration: const Duration(milliseconds: 500),
builder: (context, value, child) => Text(
'$value',
style: Theme.of(context).textTheme.headlineMedium,
),
),
],
),
),
floatingActionButton: FloatingActionButton.extended(
onPressed: _incrementCounter,
tooltip: 'Increment 1000',
label: const Text('Increment 1000'),
icon: const Icon(Icons.add),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment