Skip to content

Instantly share code, notes, and snippets.

@Roaa94
Last active March 24, 2022 20:22
Show Gist options
  • Save Roaa94/31452b543c6fd35ab2e65ac7c511919d to your computer and use it in GitHub Desktop.
Save Roaa94/31452b543c6fd35ab2e65ac7c511919d to your computer and use it in GitHub Desktop.
Animated Flutter Logo Size
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