Skip to content

Instantly share code, notes, and snippets.

@FlutterZeroGit
Last active July 13, 2022 00:28
Show Gist options
  • Save FlutterZeroGit/d69398fe692c362b2799ab2bcbbce1bc to your computer and use it in GitHub Desktop.
Save FlutterZeroGit/d69398fe692c362b2799ab2bcbbce1bc to your computer and use it in GitHub Desktop.
AnimatedContainer
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