@@ -11,30 +11,20 @@ steps:
11
11
path : quiz/ios/Runner.xcodeproj/project.pbxproj
12
12
- name : Remove README
13
13
rm : quiz/README.md
14
- - name : Replace pubspec.yaml
14
+ - name : Add deps
15
+ path : quiz
16
+ flutter : pub add animations
17
+ - name : Patch pubspec.yaml
15
18
path : quiz/pubspec.yaml
16
- replace-contents : |
17
- name: quiz
18
- description: A quiz app for demonstrating animation effects in Flutter
19
- publish_to: "none"
20
- version: 1.0.0
21
-
22
- environment:
23
- sdk: ^3.8.0-0
24
-
25
- dependencies:
26
- animations: ^2.0.0
27
- flutter:
28
- sdk: flutter
29
-
30
- dev_dependencies:
31
- flutter_test:
32
- sdk: flutter
33
- flutter_lints: ^4.0.0
34
-
35
-
36
- flutter:
37
- uses-material-design: true
19
+ patch-u : |
20
+ --- b/animations/step_01/pubspec.yaml
21
+ +++ a/animations/step_01/pubspec.yaml
22
+ @@ -1,5 +1,5 @@
23
+ name: quiz
24
+ -description: "A new Flutter project."
25
+ +description: "A quiz app for demonstrating animation effects in Flutter."
26
+ publish_to: 'none'
27
+ version: 0.1.0
38
28
- name : Replace analysis_options.yaml
39
29
path : quiz/analysis_options.yaml
40
30
replace-contents : |
@@ -99,16 +89,16 @@ steps:
99
89
path : quiz/lib/main.dart
100
90
replace-contents : |
101
91
import 'package:flutter/material.dart';
102
-
92
+
103
93
import 'home_screen.dart';
104
-
94
+
105
95
void main() {
106
96
runApp(MainApp());
107
97
}
108
-
98
+
109
99
class MainApp extends StatelessWidget {
110
100
const MainApp({super.key});
111
-
101
+
112
102
@override
113
103
Widget build(BuildContext context) {
114
104
return MaterialApp(
@@ -180,7 +170,7 @@ steps:
180
170
replace-contents : |
181
171
import 'package:flutter/cupertino.dart';
182
172
import 'model.dart';
183
-
173
+
184
174
class QuizViewModel extends ChangeNotifier {
185
175
final QuestionBank _questionBank = QuestionBank();
186
176
final VoidCallback onGameOver;
@@ -190,34 +180,34 @@ steps:
190
180
int score = 0;
191
181
bool didAnswerQuestion = false;
192
182
bool get hasNextQuestion => answeredQuestionCount < totalQuestions;
193
-
183
+
194
184
QuizViewModel({required this.onGameOver}) {
195
185
totalQuestions = _questionBank.remainingQuestions;
196
186
getNextQuestion();
197
187
}
198
-
188
+
199
189
void getNextQuestion() {
200
190
if (_questionBank.hasNextQuestion) {
201
191
currentQuestion = _questionBank.getRandomQuestion();
202
192
answeredQuestionCount++;
203
193
}
204
-
194
+
205
195
didAnswerQuestion = false;
206
-
196
+
207
197
notifyListeners();
208
198
}
209
-
199
+
210
200
void checkAnswer(int selectedIndex) {
211
201
if (!didAnswerQuestion && currentQuestion?.correctAnswer == selectedIndex) {
212
202
score++;
213
203
}
214
-
204
+
215
205
didAnswerQuestion = true;
216
-
206
+
217
207
if (!_questionBank.hasNextQuestion) {
218
208
onGameOver();
219
209
}
220
-
210
+
221
211
notifyListeners();
222
212
}
223
213
}
@@ -464,7 +454,7 @@ steps:
464
454
import 'package:flutter/material.dart';
465
455
+import 'scoreboard.dart';
466
456
import 'view_model.dart';
467
-
457
+
468
458
class QuestionScreen extends StatefulWidget {
469
459
@@ -159,13 +160,9 @@ class StatusBar extends StatelessWidget {
470
460
child: Row(
@@ -589,9 +579,9 @@ steps:
589
579
final Color _deactivatedColor = Colors.grey.shade400;
590
580
final Color _activatedColor = Colors.yellow.shade700;
591
581
+ final Curve _curve = Curves.elasticOut;
592
-
582
+
593
583
AnimatedStar({super.key, required this.isActive});
594
-
584
+
595
585
@@ -37,8 +38,10 @@ class AnimatedStar extends StatelessWidget {
596
586
Widget build(BuildContext context) {
597
587
return AnimatedScale(
@@ -618,7 +608,7 @@ steps:
618
608
--- b/animations/step_03_a/lib/question_screen.dart
619
609
+++ a/animations/step_03_a/lib/question_screen.dart
620
610
@@ -85,13 +85,17 @@ class QuestionCard extends StatelessWidget {
621
-
611
+
622
612
@override
623
613
Widget build(BuildContext context) {
624
614
- return Card(
@@ -703,7 +693,7 @@ steps:
703
693
- name : Copy step_03_c
704
694
copydir :
705
695
from : quiz
706
- to : step_03_c
696
+ to : step_03_c
707
697
708
698
- name : step_03_d
709
699
steps :
@@ -825,7 +815,7 @@ steps:
825
815
+import 'flip_effect.dart';
826
816
import 'scoreboard.dart';
827
817
import 'view_model.dart';
828
-
818
+
829
819
@@ -148,21 +149,24 @@ class AnswerCards extends StatelessWidget {
830
820
if (correctAnswer == index) {
831
821
color = Theme.of(context).colorScheme.tertiaryContainer;
@@ -885,14 +875,14 @@ steps:
885
875
final Widget child;
886
876
final Duration duration;
887
877
+ final double delayAmount;
888
-
878
+
889
879
const CardFlipEffect({
890
880
super.key,
891
881
required this.child,
892
882
required this.duration,
893
883
+ required this.delayAmount,
894
884
});
895
-
885
+
896
886
@override
897
887
- name : Patch lib/question_screen.dart
898
888
path : quiz/lib/question_screen.dart
@@ -926,17 +916,17 @@ steps:
926
916
late final AnimationController _animationController;
927
917
Widget? _previousChild;
928
918
+ late final Animation<double> _animationWithDelay;
929
-
919
+
930
920
@override
931
921
void initState() {
932
922
@@ -29,7 +30,7 @@ class _CardFlipEffectState extends State<CardFlipEffect>
933
-
923
+
934
924
_animationController = AnimationController(
935
925
vsync: this,
936
926
- duration: widget.duration,
937
927
+ duration: widget.duration * (widget.delayAmount + 1),
938
928
);
939
-
929
+
940
930
_animationController.addListener(() {
941
931
@@ -37,6 +38,15 @@ class _CardFlipEffectState extends State<CardFlipEffect>
942
932
_animationController.reset();
@@ -952,7 +942,7 @@ steps:
952
942
+ TweenSequenceItem(tween: Tween(begin: 0.0, end: 1.0), weight: 1.0),
953
943
+ ]).animate(_animationController);
954
944
}
955
-
945
+
956
946
@override
957
947
- name : Copy step_04_c
958
948
copydir :
@@ -1039,7 +1029,7 @@ steps:
1039
1029
+import 'package:animations/animations.dart';
1040
1030
import 'package:flutter/material.dart';
1041
1031
import 'question_screen.dart';
1042
-
1032
+
1043
1033
@@ -30,8 +31,9 @@ class HomeScreen extends StatelessWidget {
1044
1034
},
1045
1035
transitionsBuilder:
@@ -1060,7 +1050,7 @@ steps:
1060
1050
@@ -1,3 +1,4 @@
1061
1051
+import 'package:animations/animations.dart';
1062
1052
import 'package:flutter/material.dart';
1063
-
1053
+
1064
1054
import 'home_screen.dart';
1065
1055
@@ -15,6 +16,15 @@ class MainApp extends StatelessWidget {
1066
1056
debugShowCheckedModeBanner: false,
@@ -1096,7 +1086,7 @@ steps:
1096
1086
-import 'package:animations/animations.dart';
1097
1087
import 'package:flutter/material.dart';
1098
1088
import 'question_screen.dart';
1099
-
1089
+
1100
1090
@@ -25,18 +24,10 @@ class HomeScreen extends StatelessWidget {
1101
1091
// Show the question screen to start the game
1102
1092
Navigator.push(
@@ -1129,7 +1119,7 @@ steps:
1129
1119
import 'flip_effect.dart';
1130
1120
import 'scoreboard.dart';
1131
1121
@@ -86,28 +87,15 @@ class QuestionCard extends StatelessWidget {
1132
-
1122
+
1133
1123
@override
1134
1124
Widget build(BuildContext context) {
1135
1125
- return AnimatedSwitcher(
@@ -1184,7 +1174,7 @@ steps:
1184
1174
onGameOver: _handleGameOver,
1185
1175
);
1186
1176
+ VoidCallback? _showGameOverScreen;
1187
-
1177
+
1188
1178
@override
1189
1179
Widget build(BuildContext context) {
1190
1180
@@ -38,7 +39,11 @@ class _QuestionScreenState extends State<QuestionScreen> {
@@ -1203,7 +1193,7 @@ steps:
1203
1193
@@ -58,24 +63,47 @@ class _QuestionScreenState extends State<QuestionScreen> {
1204
1194
);
1205
1195
}
1206
-
1196
+
1207
1197
+ void _handleChangeOpenContainer(VoidCallback openContainer) {
1208
1198
+ _showGameOverScreen = openContainer;
1209
1199
+ }
@@ -1263,7 +1253,7 @@ steps:
1263
1253
@@ -83,14 +111,22 @@ class _QuestionScreenState extends State<QuestionScreen> {
1264
1254
class QuestionCard extends StatelessWidget {
1265
1255
final String? question;
1266
-
1256
+
1267
1257
- const QuestionCard({required this.question, super.key});
1268
1258
+ const QuestionCard({
1269
1259
+ required this.onChangeOpenContainer,
@@ -1276,7 +1266,7 @@ steps:
1276
1266
+ final QuizViewModel viewModel;
1277
1267
+
1278
1268
+ static const _backgroundColor = Color(0xfff2f3fa);
1279
-
1269
+
1280
1270
@override
1281
1271
Widget build(BuildContext context) {
1282
1272
return PageTransitionSwitcher(
@@ -1335,28 +1325,28 @@ steps:
1335
1325
path : quiz
1336
1326
dart : analyze --fatal-infos
1337
1327
- name : Build Android app
1338
- platforms : [ macos ]
1328
+ platforms : [macos]
1339
1329
path : quiz
1340
1330
flutter : build apk
1341
1331
- name : Build iOS app
1342
- platforms : [ macos ]
1332
+ platforms : [macos]
1343
1333
path : quiz
1344
1334
flutter : build ios --simulator
1345
1335
- name : Build macOS app
1346
- platforms : [ macos ]
1336
+ platforms : [macos]
1347
1337
path : quiz
1348
1338
flutter : build macos
1349
1339
- name : Build Linux app
1350
- platforms : [ linux ]
1340
+ platforms : [linux]
1351
1341
path : quiz
1352
1342
flutter : build linux
1353
1343
- name : Build Windows app
1354
- platforms : [ windows ]
1344
+ platforms : [windows]
1355
1345
path : quiz
1356
1346
flutter : build windows
1357
1347
- name : Build Web app
1358
1348
path : quiz
1359
1349
flutter : build web
1360
1350
1361
1351
- name : Cleanup
1362
- rmdir : quiz
1352
+ rmdir : quiz
0 commit comments