Skip to content

Instantly share code, notes, and snippets.

@Lootwig
Created August 29, 2023 11:55
Show Gist options
  • Save Lootwig/b2224f73129986afdc88b4d0b191ce6e to your computer and use it in GitHub Desktop.
Save Lootwig/b2224f73129986afdc88b4d0b191ce6e to your computer and use it in GitHub Desktop.
solar-midnight-7981
import 'package:flutter/material.dart';
import 'package:flutter_animate/flutter_animate.dart';
void main() {
runApp(Home());
}
class Home extends StatefulWidget {
const Home({
super.key,
});
@override
State<Home> createState() => _HomeState();
}
class _HomeState extends State<Home> {
double _value = 0;
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
...List.filled(
5,
const SizedBox.shrink().animate(target: _value).swap(
builder: (context, child) => Container(
height: 50,
color: Colors.red,
),
),
),
ElevatedButton(
onPressed: () => setState(
() => _value == 0 ? _value = 1 : _value = 0,
),
child: const Text('Swap'),
),
],
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment