Thanks to the animate_do project for giving me development inspiration.
Thanks to the animate.css project for giving me the visual experience.
This project is my personal learning project (if successful, it will be integrated into the project of my company).
- Learn the basic layout effects of Flutter;
- Learn the Flutter Animate effect and create the corresponding animation component library;
demo_flutter_animate_simple.mov
flutter_animate:
git:
url: https://github.com/harrischen/flutter_animate.git
ref: mainimport 'package:flutter/material.dart';
import 'package:flutter_animate/flutter_animate.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(primarySwatch: Colors.blue),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
bool isAnimate = false;
void _changeToEnd() => setState(() => isAnimate = true);
void _changeToStart() => setState(() => isAnimate = false);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text(widget.title)),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
height: 160.0,
child: Row(
children: [
Expanded(
child: isAnimate
? Flip(
child: const DemoIcon(),
completed: _changeToStart,
)
: const DemoIcon(),
),
Expanded(
child: isAnimate
? FlipInX(
child: const DemoIcon(),
completed: _changeToStart,
)
: const DemoIcon(),
),
Expanded(
child: isAnimate
? FlipInY(
child: const DemoIcon(),
completed: _changeToStart,
)
: const DemoIcon(),
)
],
),
),
ElevatedButton(
child: Text(isAnimate ? 'In Animation' : 'Play'),
onPressed: _changeToEnd,
),
],
),
),
);
}
}
class DemoIcon extends StatelessWidget {
const DemoIcon({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const Icon(
Icons.adb_rounded,
size: 56.0,
);
}
}- bounce
- flash
- pulse
- rubberBand
- shakeX
- shakeY
- headShake
- swing
- tada
- wobble
- jello
- heartBeat
- backInDown
- backInLeft
- backInRight
- backInUp
- backOutDown
- backOutLeft
- backOutRight
- backOutUp
- bounceIn
- bounceInDown
- bounceInLeft
- bounceInRight
- bounceInUp
- bounceOut
- bounceOutDown
- bounceOutLeft
- bounceOutRight
- bounceOutUp
- fadeIn
- fadeInDown
- fadeInLeft
- fadeInRight
- fadeInUp
- fadeInTopLeft
- fadeInTopRight
- fadeInBottomLeft
- fadeInBottomRight
- fadeOut
- fadeOutDown
- fadeOutLeft
- fadeOutRight
- fadeOutUp
- fadeOutTopLeft
- fadeOutTopRight
- fadeOutBottomRight
- fadeOutBottomLeft
- flip
- flipInX
- flipInY
- flipOutX
- flipOutY
- lightSpeedInRight
- lightSpeedInLeft
- lightSpeedOutRight
- lightSpeedOutLeft
- rotateIn
- rotateInDownLeft
- rotateInDownRight
- rotateInUpLeft
- rotateInUpRight
- rotateOut
- rotateOutDownLeft
- rotateOutDownRight
- rotateOutUpLeft
- rotateOutUpRight
- hinge
- jackInTheBox
- rollInLeft
- rollInRight
- rollOutLeft
- rollOutRight
- zoomIn
- zoomInDown
- zoomInLeft
- zoomInRight
- zoomInUp
- zoomOut
- zoomOutDown
- zoomOutLeft
- zoomOutRight
- zoomOutUp
- slideInDown
- slideInLeft
- slideInRight
- slideInUp
- slideOutDown
- slideOutLeft
- slideOutRight
- slideOutUp
[✓] Flutter (Channel stable, 2.5.1, on macOS 11.6 20G165 darwin-x64, locale zh-Hans-CN)
• Flutter version 2.5.1 at /usr/local/Caskroom/flutter/2.5.1/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision ffb2ecea52 (9 weeks ago), 2021-09-17 15:26:33 -0400
• Engine revision b3af521a05
• Dart version 2.14.2