Skip to content

Commit cfa3cf5

Browse files
Properly split up animations (#2258)
1 parent e438857 commit cfa3cf5

File tree

1,687 files changed

+62450
-38
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,687 files changed

+62450
-38
lines changed

animations/codelab_rebuild.yaml

Lines changed: 129 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ name: Add animation effects to your Flutter app
22
steps:
33
- name: step_01
44
steps:
5-
- name: Remove generated code
6-
rmdir: step_01
75
- name: Create project
86
flutter: create --empty quiz
97
- name: Strip DEVELOPMENT_TEAM
@@ -40,13 +38,17 @@ steps:
4038
replace-contents: |
4139
include: package:flutter_lints/flutter.yaml
4240
41+
analyzer:
42+
errors:
43+
unused_field: ignore
44+
4345
linter:
4446
rules:
47+
annotate_overrides: false
4548
prefer_const_constructors: false
4649
prefer_const_constructors_in_immutables: false
4750
prefer_const_declarations: false
4851
prefer_const_literals_to_create_immutables: false
49-
annotate_overrides: false
5052
- name: Create the HomeScreen
5153
path: quiz/lib/home_screen.dart
5254
replace-contents: |
@@ -410,18 +412,14 @@ steps:
410412
);
411413
}
412414
}
413-
# - name: Build web app
414-
# path: patterns_codelab
415-
# flutter: build web
416415
- name: Fetch dependencies
417416
path: quiz
418417
dart: pub get
419418
- name: Run Dart Analzyer
420419
path: quiz
421420
dart: analyze --fatal-infos
422-
# - name: Check formatting
423-
# path: quiz
424-
# dart: format --set-exit-if-changed
421+
- name: Remove step_01
422+
rmdir: step_01
425423
- name: Copy step_01
426424
copydir:
427425
from: quiz
@@ -462,6 +460,12 @@ steps:
462460
);
463461
}
464462
}
463+
- name: Remove step_02_a
464+
rmdir: step_02_a
465+
- name: Copy step_02_a
466+
copydir:
467+
from: quiz
468+
to: step_02_a
465469
- name: Use Scoreboard widget
466470
path: quiz/lib/question_screen.dart
467471
patch-u: |
@@ -490,6 +494,12 @@ steps:
490494
),
491495
],
492496
),
497+
- name: Remove step_02_b
498+
rmdir: step_02_b
499+
- name: Copy step_02_b
500+
copydir:
501+
from: quiz
502+
to: step_02_b
493503
- name: Use an ImplicitlyAnimatedWidget
494504
path: quiz/lib/scoreboard.dart
495505
patch-u: |
@@ -534,6 +544,12 @@ steps:
534544
+ );
535545
+ }
536546
+}
547+
- name: Remove step_02_c
548+
rmdir: step_02_c
549+
- name: Copy step_02_c
550+
copydir:
551+
from: quiz
552+
to: step_02_c
537553
- name: Use a TweenAnimationBuilder to change the color
538554
path: quiz/lib/scoreboard.dart
539555
patch-u: |
@@ -563,6 +579,12 @@ steps:
563579
),
564580
);
565581
}
582+
- name: Remove step_02_d
583+
rmdir: step_02_d
584+
- name: Copy step_02_d
585+
copydir:
586+
from: quiz
587+
to: step_02_d
566588
- name: Use a Curve
567589
path: quiz/lib/scoreboard.dart
568590
patch-u: |
@@ -587,7 +609,15 @@ steps:
587609
duration: _duration,
588610
tween: ColorTween(
589611
begin: _deactivatedColor,
590-
612+
- name: Remove step_02_e
613+
rmdir: step_02_e
614+
- name: Copy step_02_e
615+
copydir:
616+
from: quiz
617+
to: step_02_e
618+
# TODO(DomesticMouse): Delete step_02 once the codelab is published with individual steps
619+
- name: Remove step_02
620+
rmdir: step_02
591621
- name: Copy step_02
592622
copydir:
593623
from: quiz
@@ -597,9 +627,9 @@ steps:
597627
- name: Use AnimatedSwitcher
598628
path: quiz/lib/question_screen.dart
599629
patch-u: |
600-
--- a/animations/step_02/lib/question_screen.dart
601-
+++ b/animations/step_02/lib/question_screen.dart
602-
@@ -88,13 +88,17 @@ class QuestionCard extends StatelessWidget {
630+
--- b/animations/step_03_a/lib/question_screen.dart
631+
+++ a/animations/step_03_a/lib/question_screen.dart
632+
@@ -87,13 +87,17 @@ class QuestionCard extends StatelessWidget {
603633
604634
@override
605635
Widget build(BuildContext context) {
@@ -624,6 +654,12 @@ steps:
624654
),
625655
),
626656
);
657+
- name: Remove step_03_a
658+
rmdir: step_03_a
659+
- name: Copy step_03_a
660+
copydir:
661+
from: quiz
662+
to: step_03_a
627663
- name: Use a custom transitionBuilder
628664
path: quiz/lib/question_screen.dart
629665
patch-u: |
@@ -644,6 +680,12 @@ steps:
644680
duration: const Duration(milliseconds: 300),
645681
child: Card(
646682
key: ValueKey(question),
683+
- name: Remove step_03_b
684+
rmdir: step_03_b
685+
- name: Copy step_03_b
686+
copydir:
687+
from: quiz
688+
to: step_03_b
647689
- name: Apply a fade effect to the transitionBuilder
648690
path: quiz/lib/question_screen.dart
649691
patch-u: |
@@ -662,6 +704,12 @@ steps:
662704
},
663705
duration: const Duration(milliseconds: 300),
664706
child: Card(
707+
- name: Remove step_03_c
708+
rmdir: step_03_c
709+
- name: Copy step_03_c
710+
copydir:
711+
from: quiz
712+
to: step_03_c
665713
- name: Customize the layoutBuilder
666714
path: quiz/lib/question_screen.dart
667715
patch-u: |
@@ -683,6 +731,15 @@ steps:
683731
transitionBuilder: (Widget child, Animation<double> animation) {
684732
final curveAnimation =
685733
CurveTween(curve: Curves.easeInCubic).animate(animation);
734+
- name: Remove step_03_d
735+
rmdir: step_03_d
736+
- name: Copy step_03_d
737+
copydir:
738+
from: quiz
739+
to: step_03_d
740+
# TODO(DomesticMouse): Delete step_03 once the codelab is published with individual steps
741+
- name: Remove step_03
742+
rmdir: step_03
686743
- name: Copy step_03
687744
copydir:
688745
from: quiz
@@ -718,8 +775,8 @@ steps:
718775
void initState() {
719776
super.initState();
720777
721-
_animationController = AnimationController(
722-
vsync: this, duration: widget.duration);
778+
_animationController =
779+
AnimationController(vsync: this, duration: widget.duration);
723780
724781
_animationController.addListener(() {
725782
if (_animationController.value == 1) {
@@ -814,6 +871,12 @@ steps:
814871
),
815872
),
816873
),
874+
- name: Remove step_04_a
875+
rmdir: step_04_a
876+
- name: Copy step_04_a
877+
copydir:
878+
from: quiz
879+
to: step_04_a
817880
- name: Add delay using TweenSequence
818881
path: quiz/lib/flip_effect.dart
819882
patch-u: |
@@ -833,7 +896,31 @@ steps:
833896
});
834897
835898
@override
836-
@@ -19,19 +21,32 @@ class _CardFlipEffectState extends State<CardFlipEffect>
899+
- name: Add delay to question screen
900+
path: quiz/lib/question_screen.dart
901+
patch-u: |
902+
--- a/animations/step_04/lib/question_screen.dart
903+
+++ b/animations/step_04/lib/question_screen.dart
904+
@@ -151,6 +151,7 @@ class AnswerCards extends StatelessWidget {
905+
}
906+
907+
return CardFlipEffect(
908+
+ delayAmount: index.toDouble() / 2,
909+
duration: const Duration(milliseconds: 300),
910+
child: Card.filled(
911+
key: ValueKey(answers[index]),
912+
- name: Remove step_04_b
913+
rmdir: step_04_b
914+
- name: Copy step_04_b
915+
copydir:
916+
from: quiz
917+
to: step_04_b
918+
- name: Add delay using TweenSequence, part 2
919+
path: quiz/lib/flip_effect.dart
920+
patch-u: |
921+
--- b/animations/step_04_c/lib/flip_effect.dart
922+
+++ a/animations/step_04_c/lib/flip_effect.dart
923+
@@ -21,19 +21,32 @@ class _CardFlipEffectState extends State<CardFlipEffect>
837924
with SingleTickerProviderStateMixin {
838925
late final AnimationController _animationController;
839926
Widget? _previousChild;
@@ -843,8 +930,9 @@ steps:
843930
void initState() {
844931
super.initState();
845932
846-
_animationController = AnimationController(
847-
- vsync: this, duration: widget.duration);
933+
- _animationController =
934+
- AnimationController(vsync: this, duration: widget.duration);
935+
+ _animationController = AnimationController(
848936
+ vsync: this, duration: widget.duration * (widget.delayAmount + 1));
849937
850938
_animationController.addListener(() {
@@ -867,7 +955,18 @@ steps:
867955
}
868956
869957
@override
870-
@@ -51,14 +66,14 @@ class _CardFlipEffectState extends State<CardFlipEffect>
958+
- name: Remove step_04_c
959+
rmdir: step_04_c
960+
- name: Copy step_04_c
961+
copydir:
962+
from: quiz
963+
to: step_04_c
964+
- name: Add delay using TweenSequence, part 3
965+
path: quiz/lib/flip_effect.dart
966+
patch-u: |
967+
--- b/animations/step_04_d/lib/flip_effect.dart
968+
+++ a/animations/step_04_d/lib/flip_effect.dart
969+
@@ -66,14 +66,14 @@ class _CardFlipEffectState extends State<CardFlipEffect>
871970
@override
872971
Widget build(BuildContext context) {
873972
return AnimatedBuilder(
@@ -885,19 +984,15 @@ steps:
885984
? _previousChild
886985
: Transform.flip(flipY: true, child: widget.child)
887986
: widget.child,
888-
- name: Add delay to question screen
889-
path: quiz/lib/question_screen.dart
890-
patch-u: |
891-
--- a/animations/step_04/lib/question_screen.dart
892-
+++ b/animations/step_04/lib/question_screen.dart
893-
@@ -151,6 +151,7 @@ class AnswerCards extends StatelessWidget {
894-
}
895-
896-
return CardFlipEffect(
897-
+ delayAmount: index.toDouble() / 2,
898-
duration: const Duration(milliseconds: 300),
899-
child: Card.filled(
900-
key: ValueKey(answers[index]),
987+
- name: Remove step_04_d
988+
rmdir: step_04_d
989+
- name: Copy step_04_d
990+
copydir:
991+
from: quiz
992+
to: step_04_d
993+
# TODO(DomesticMouse): Delete step_04 once the codelab is published with individual steps
994+
- name: Remove step_04
995+
rmdir: step_04
901996
- name: Copy step_04
902997
copydir:
903998
from: quiz
@@ -983,7 +1078,6 @@ steps:
9831078
),
9841079
home: HomeScreen(),
9851080
);
986-
9871081
- name: Change back to MaterialPageRoute
9881082
path: quiz/lib/home_screen.dart
9891083
patch-u: |
@@ -1262,6 +1356,8 @@ steps:
12621356
- name: Build Web app
12631357
path: quiz
12641358
flutter: build web
1359+
- name: Remove step_05
1360+
rmdir: step_05
12651361
- name: Copy step_05
12661362
copydir:
12671363
from: quiz

animations/step_01/analysis_options.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
include: package:flutter_lints/flutter.yaml
22

3+
analyzer:
4+
errors:
5+
unused_field: ignore
6+
37
linter:
48
rules:
9+
annotate_overrides: false
510
prefer_const_constructors: false
611
prefer_const_constructors_in_immutables: false
712
prefer_const_declarations: false
813
prefer_const_literals_to_create_immutables: false
9-
annotate_overrides: false

animations/step_02/analysis_options.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
include: package:flutter_lints/flutter.yaml
22

3+
analyzer:
4+
errors:
5+
unused_field: ignore
6+
37
linter:
48
rules:
9+
annotate_overrides: false
510
prefer_const_constructors: false
611
prefer_const_constructors_in_immutables: false
712
prefer_const_declarations: false
813
prefer_const_literals_to_create_immutables: false
9-
annotate_overrides: false

animations/step_02_a/.gitignore

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
migrate_working_dir/
12+
13+
# IntelliJ related
14+
*.iml
15+
*.ipr
16+
*.iws
17+
.idea/
18+
19+
# The .vscode folder contains launch configuration and tasks you configure in
20+
# VS Code which you may wish to be included in version control, so this line
21+
# is commented out by default.
22+
#.vscode/
23+
24+
# Flutter/Dart/Pub related
25+
**/doc/api/
26+
**/ios/Flutter/.last_build_id
27+
.dart_tool/
28+
.flutter-plugins
29+
.flutter-plugins-dependencies
30+
.pub-cache/
31+
.pub/
32+
/build/
33+
34+
# Symbolication related
35+
app.*.symbols
36+
37+
# Obfuscation related
38+
app.*.map.json
39+
40+
# Android Studio will place build artifacts here
41+
/android/app/debug
42+
/android/app/profile
43+
/android/app/release

0 commit comments

Comments
 (0)