Last active
March 24, 2022 20:22
-
-
Save Roaa94/31452b543c6fd35ab2e65ac7c511919d to your computer and use it in GitHub Desktop.
Animated Flutter Logo Size
This file contains hidden or 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 StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter Starter', | |
debugShowCheckedModeBanner: false, | |
theme: ThemeData( | |
primarySwatch: Colors.blue, | |
), | |
home: Example(), | |
); | |
} | |
} | |
class Example extends StatefulWidget { | |
@override | |
State<Example> createState() => _ExampleState(); | |
} | |
class _ExampleState extends State<Example> { | |
bool largeSize = false; | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
body: Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
crossAxisAlignment: CrossAxisAlignment.center, | |
children: [ | |
AnimatedContainer( | |
duration: const Duration(milliseconds: 300), | |
child: FlutterLogo(size: largeSize ? 300 : 200), | |
), | |
AnimatedSwitcher( | |
duration: const Duration(milliseconds: 300), | |
child: largeSize ? const FlutterLogo(size: 300) : const FlutterLogo(size: 200), | |
), | |
ElevatedButton( | |
onPressed: () => setState(() => largeSize = !largeSize), | |
child: const Text('Toggle Size'), | |
), | |
], | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment