Created with <3 with dartpad.dev.
Created
August 29, 2023 11:55
-
-
Save Lootwig/b2224f73129986afdc88b4d0b191ce6e to your computer and use it in GitHub Desktop.
solar-midnight-7981
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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