Last active
July 13, 2022 00:28
-
-
Save FlutterZeroGit/d69398fe692c362b2799ab2bcbbce1bc to your computer and use it in GitHub Desktop.
AnimatedContainer
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'; | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatefulWidget { | |
@override | |
State<MyApp> createState() => _MyAppState(); | |
} | |
class _MyAppState extends State<MyApp> { | |
bool selected = false; | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: Scaffold( | |
appBar: AppBar(title: Text('FlutterZero')), | |
body: Center( | |
child: GestureDetector( | |
onTap: (() => setState(() { | |
selected = !selected; | |
})), | |
child: AnimatedContainer( | |
width: selected ? 150 : 100, | |
height: selected ? 150 : 100, | |
color: selected ? Colors.orange : Colors.yellow, | |
alignment: selected ? Alignment.bottomRight : Alignment.center, | |
duration: Duration(seconds: 1), | |
child: FlutterLogo(size: 50), | |
), | |
), | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment