Skip to content

Commit 751dbd0

Browse files
committed
Use flutter/codelabs analysis options
1 parent 5da0f72 commit 751dbd0

Some content is hidden

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

60 files changed

+157
-156
lines changed

analysis_options.yaml

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

3-
analyzer:
4-
language:
5-
strict-casts: true
6-
strict-inference: true
7-
83
linter:
94
rules:
105
avoid_types_on_closure_parameters: true

animations/codelab_rebuild.yaml

Lines changed: 54 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ steps:
3838
- name: Replace analysis_options.yaml
3939
path: quiz/analysis_options.yaml
4040
replace-contents: |
41-
include: package:flutter_lints/flutter.yaml
41+
include: ../../analysis_options.yaml
4242
4343
analyzer:
4444
errors:
@@ -56,10 +56,10 @@ steps:
5656
replace-contents: |
5757
import 'package:flutter/material.dart';
5858
import 'question_screen.dart';
59-
59+
6060
class HomeScreen extends StatelessWidget {
6161
const HomeScreen({super.key});
62-
62+
6363
@override
6464
Widget build(BuildContext context) {
6565
return Scaffold(
@@ -83,7 +83,7 @@ steps:
8383
Navigator.push(
8484
context,
8585
MaterialPageRoute(
86-
builder: (BuildContext context) {
86+
builder: (context) {
8787
return QuestionScreen();
8888
},
8989
),
@@ -239,18 +239,18 @@ steps:
239239
replace-contents: |
240240
import 'package:flutter/material.dart';
241241
import 'view_model.dart';
242-
242+
243243
class QuestionScreen extends StatefulWidget {
244244
const QuestionScreen({super.key});
245-
245+
246246
@override
247247
State<QuestionScreen> createState() => _QuestionScreenState();
248248
}
249-
249+
250250
class _QuestionScreenState extends State<QuestionScreen> {
251251
late final QuizViewModel viewModel =
252252
QuizViewModel(onGameOver: _handleGameOver);
253-
253+
254254
@override
255255
Widget build(BuildContext context) {
256256
return ListenableBuilder(
@@ -292,7 +292,7 @@ steps:
292292
},
293293
);
294294
}
295-
295+
296296
void _handleGameOver() {
297297
showDialog(
298298
barrierDismissible: false,
@@ -314,42 +314,42 @@ steps:
314314
);
315315
}
316316
}
317-
317+
318318
class QuestionCard extends StatelessWidget {
319319
final String? question;
320-
320+
321321
const QuestionCard({
322322
required this.question,
323323
super.key,
324324
});
325-
325+
326326
@override
327327
Widget build(BuildContext context) {
328328
return Card(
329329
elevation: 4,
330330
child: Padding(
331331
padding: EdgeInsets.all(16.0),
332332
child: Text(
333-
question ?? "",
333+
question ?? '',
334334
style: Theme.of(context).textTheme.displaySmall,
335335
),
336336
),
337337
);
338338
}
339339
}
340-
340+
341341
class AnswerCards extends StatelessWidget {
342342
final List<String> answers;
343343
final ValueChanged<int> onTapped;
344344
final int? correctAnswer;
345-
345+
346346
const AnswerCards({
347347
required this.answers,
348348
required this.onTapped,
349349
required this.correctAnswer,
350350
super.key,
351351
});
352-
352+
353353
@override
354354
Widget build(BuildContext context) {
355355
return GridView.count(
@@ -373,7 +373,7 @@ steps:
373373
padding: EdgeInsets.all(16.0),
374374
child: Center(
375375
child: Text(
376-
answers.length > index ? answers[index] : "",
376+
answers.length > index ? answers[index] : '',
377377
style: Theme.of(context).textTheme.titleMedium,
378378
overflow: TextOverflow.clip,
379379
),
@@ -385,12 +385,12 @@ steps:
385385
);
386386
}
387387
}
388-
388+
389389
class StatusBar extends StatelessWidget {
390390
final QuizViewModel viewModel;
391-
391+
392392
const StatusBar({required this.viewModel, super.key});
393-
393+
394394
@override
395395
Widget build(BuildContext context) {
396396
return Card(
@@ -417,9 +417,6 @@ steps:
417417
- name: Fetch dependencies
418418
path: quiz
419419
dart: pub get
420-
- name: Run Dart Analzyer
421-
path: quiz
422-
dart: analyze --fatal-infos
423420
- name: Copy step_01
424421
copydir:
425422
from: quiz
@@ -647,7 +644,7 @@ steps:
647644
- child: Padding(
648645
- padding: EdgeInsets.all(16.0),
649646
- child: Text(
650-
- question ?? "",
647+
- question ?? '',
651648
- style: Theme.of(context).textTheme.displaySmall,
652649
+ return AnimatedSwitcher(
653650
+ duration: const Duration(milliseconds: 300),
@@ -657,7 +654,7 @@ steps:
657654
+ child: Padding(
658655
+ padding: const EdgeInsets.all(16.0),
659656
+ child: Text(
660-
+ question ?? "",
657+
+ question ?? '',
661658
+ style: Theme.of(context).textTheme.displaySmall,
662659
+ ),
663660
),
@@ -675,13 +672,13 @@ steps:
675672
- name: Patch lib/question_screen.dart
676673
path: quiz/lib/question_screen.dart
677674
patch-u: |
678-
--- a/animations/step_03/lib/question_screen.dart
679-
+++ b/animations/step_03/lib/question_screen.dart
675+
--- b/animations/step_03_b/lib/question_screen.dart
676+
+++ a/animations/step_03_b/lib/question_screen.dart
680677
@@ -88,6 +88,14 @@ class QuestionCard extends StatelessWidget {
681678
@override
682679
Widget build(BuildContext context) {
683680
return AnimatedSwitcher(
684-
+ transitionBuilder: (Widget child, Animation<double> animation) {
681+
+ transitionBuilder: (child, animation) {
685682
+ final curveAnimation =
686683
+ CurveTween(curve: Curves.easeInCubic).animate(animation);
687684
+ final offsetAnimation =
@@ -731,13 +728,13 @@ steps:
731728
- name: Patch lib/question_screen.dart
732729
path: quiz/lib/question_screen.dart
733730
patch-u: |
734-
--- a/animations/step_03/lib/question_screen.dart
735-
+++ b/animations/step_03/lib/question_screen.dart
731+
--- b/animations/step_03_d/lib/question_screen.dart
732+
+++ a/animations/step_03_d/lib/question_screen.dart
736733
@@ -88,6 +88,15 @@ class QuestionCard extends StatelessWidget {
737734
@override
738735
Widget build(BuildContext context) {
739736
return AnimatedSwitcher(
740-
+ layoutBuilder: (Widget? currentChild, List<Widget> previousChildren) {
737+
+ layoutBuilder: (currentChild, previousChildren) {
741738
+ return Stack(
742739
+ alignment: Alignment.topCenter,
743740
+ children: <Widget>[
@@ -746,7 +743,7 @@ steps:
746743
+ ],
747744
+ );
748745
+ },
749-
transitionBuilder: (Widget child, Animation<double> animation) {
746+
transitionBuilder: (child, animation) {
750747
final curveAnimation =
751748
CurveTween(curve: Curves.easeInCubic).animate(animation);
752749
- name: Copy step_03_d
@@ -761,9 +758,10 @@ steps:
761758
- name: Add lib/flip_effect.dart
762759
path: quiz/lib/flip_effect.dart
763760
replace-contents: |
764-
import 'package:flutter/widgets.dart';
765761
import 'dart:math' as math;
766762
763+
import 'package:flutter/widgets.dart';
764+
767765
class CardFlipEffect extends StatefulWidget {
768766
final Widget child;
769767
final Duration duration;
@@ -834,8 +832,8 @@ steps:
834832
- name: Patch lib/question_screen.dart
835833
path: quiz/lib/question_screen.dart
836834
patch-u: |
837-
--- a/animations/step_04/lib/question_screen.dart
838-
+++ b/animations/step_04/lib/question_screen.dart
835+
--- b/animations/step_04_a/lib/question_screen.dart
836+
+++ a/animations/step_04_a/lib/question_screen.dart
839837
@@ -1,4 +1,5 @@
840838
import 'package:flutter/material.dart';
841839
+import 'flip_effect.dart';
@@ -858,7 +856,7 @@ steps:
858856
- padding: EdgeInsets.all(16.0),
859857
- child: Center(
860858
- child: Text(
861-
- answers.length > index ? answers[index] : "",
859+
- answers.length > index ? answers[index] : '',
862860
- style: Theme.of(context).textTheme.titleMedium,
863861
- overflow: TextOverflow.clip,
864862
+
@@ -876,7 +874,7 @@ steps:
876874
+ padding: const EdgeInsets.all(16.0),
877875
+ child: Center(
878876
+ child: Text(
879-
+ answers.length > index ? answers[index] : "",
877+
+ answers.length > index ? answers[index] : '',
880878
+ style: Theme.of(context).textTheme.titleMedium,
881879
+ overflow: TextOverflow.clip,
882880
+ ),
@@ -895,9 +893,9 @@ steps:
895893
- name: Patch lib/flp_effect.dart
896894
path: quiz/lib/flip_effect.dart
897895
patch-u: |
898-
--- a/animations/step_04/lib/flip_effect.dart
899-
+++ b/animations/step_04/lib/flip_effect.dart
900-
@@ -4,11 +4,13 @@ import 'dart:math' as math;
896+
--- b/animations/step_04_b/lib/flip_effect.dart
897+
+++ a/animations/step_04_b/lib/flip_effect.dart
898+
@@ -5,11 +5,13 @@ import 'package:flutter/widgets.dart';
901899
class CardFlipEffect extends StatefulWidget {
902900
final Widget child;
903901
final Duration duration;
@@ -938,7 +936,7 @@ steps:
938936
patch-u: |
939937
--- b/animations/step_04_c/lib/flip_effect.dart
940938
+++ a/animations/step_04_c/lib/flip_effect.dart
941-
@@ -21,19 +21,32 @@ class _CardFlipEffectState extends State<CardFlipEffect>
939+
@@ -22,19 +22,32 @@ class _CardFlipEffectState extends State<CardFlipEffect>
942940
with SingleTickerProviderStateMixin {
943941
late final AnimationController _animationController;
944942
Widget? _previousChild;
@@ -987,7 +985,7 @@ steps:
987985
patch-u: |
988986
--- b/animations/step_04_d/lib/flip_effect.dart
989987
+++ a/animations/step_04_d/lib/flip_effect.dart
990-
@@ -66,14 +66,14 @@ class _CardFlipEffectState extends State<CardFlipEffect>
988+
@@ -67,14 +67,14 @@ class _CardFlipEffectState extends State<CardFlipEffect>
991989
@override
992990
Widget build(BuildContext context) {
993991
return AnimatedBuilder(
@@ -1024,7 +1022,7 @@ steps:
10241022
Navigator.push(
10251023
context,
10261024
- MaterialPageRoute(
1027-
- builder: (BuildContext context) {
1025+
- builder: (context) {
10281026
- return QuestionScreen();
10291027
- },
10301028
- ),
@@ -1142,8 +1140,8 @@ steps:
11421140
- name: Patch lib/question_screen.dart
11431141
path: quiz/lib/question_screen.dart
11441142
patch-u: |
1145-
--- a/animations/step_05/lib/question_screen.dart
1146-
+++ b/animations/step_05/lib/question_screen.dart
1143+
--- b/animations/step_05_c/lib/question_screen.dart
1144+
+++ a/animations/step_05_c/lib/question_screen.dart
11471145
@@ -1,3 +1,4 @@
11481146
+import 'package:animations/animations.dart';
11491147
import 'package:flutter/material.dart';
@@ -1154,10 +1152,10 @@ steps:
11541152
@override
11551153
Widget build(BuildContext context) {
11561154
- return AnimatedSwitcher(
1157-
- layoutBuilder: (Widget? currentChild, List<Widget> previousChildren) {
1155+
- layoutBuilder: (currentChild, previousChildren) {
11581156
+ return PageTransitionSwitcher(
11591157
+ duration: const Duration(milliseconds: 200),
1160-
+ layoutBuilder: (List<Widget> entries) {
1158+
+ layoutBuilder: (entries) {
11611159
return Stack(
11621160
alignment: Alignment.topCenter,
11631161
children: <Widget>[
@@ -1167,7 +1165,7 @@ steps:
11671165
],
11681166
);
11691167
},
1170-
- transitionBuilder: (Widget child, Animation<double> animation) {
1168+
- transitionBuilder: (child, animation) {
11711169
- final curveAnimation =
11721170
- CurveTween(curve: Curves.easeInCubic).animate(animation);
11731171
- final offsetAnimation =
@@ -1177,7 +1175,7 @@ steps:
11771175
- return FadeTransition(
11781176
- opacity: fadeInAnimation,
11791177
- child: SlideTransition(position: offsetAnimation, child: child),
1180-
+ transitionBuilder: (Widget child, animation, secondaryAnimation) {
1178+
+ transitionBuilder: (child, animation, secondaryAnimation) {
11811179
+ return FadeThroughTransition(
11821180
+ animation: animation,
11831181
+ secondaryAnimation: secondaryAnimation,
@@ -1199,9 +1197,9 @@ steps:
11991197
rmdir: step_05_d
12001198
- name: Patch lib/question_screen.dart
12011199
path: quiz/lib/question_screen.dart
1202-
patch-u: |
1203-
--- a/animations/step_05/lib/question_screen.dart
1204-
+++ b/animations/step_05/lib/question_screen.dart
1200+
patch-u: |
1201+
--- b/animations/step_05_d/lib/question_screen.dart
1202+
+++ a/animations/step_05_d/lib/question_screen.dart
12051203
@@ -14,6 +14,7 @@ class QuestionScreen extends StatefulWidget {
12061204
class _QuestionScreenState extends State<QuestionScreen> {
12071205
late final QuizViewModel viewModel =
@@ -1321,15 +1319,15 @@ steps:
13211319
Widget build(BuildContext context) {
13221320
return PageTransitionSwitcher(
13231321
duration: const Duration(milliseconds: 200),
1324-
- layoutBuilder: (List<Widget> entries) {
1322+
- layoutBuilder: (entries) {
13251323
- return Stack(
13261324
- alignment: Alignment.topCenter,
13271325
- children: <Widget>[
13281326
- ...entries,
13291327
- ],
13301328
- );
13311329
- },
1332-
transitionBuilder: (Widget child, animation, secondaryAnimation) {
1330+
transitionBuilder: (child, animation, secondaryAnimation) {
13331331
return FadeThroughTransition(
13341332
animation: animation,
13351333
@@ -106,16 +142,30 @@ class QuestionCard extends StatelessWidget {
@@ -1343,7 +1341,7 @@ steps:
13431341
- child: Padding(
13441342
- padding: const EdgeInsets.all(16.0),
13451343
- child: Text(
1346-
- question ?? "",
1344+
- question ?? '',
13471345
- style: Theme.of(context).textTheme.displaySmall,
13481346
- ),
13491347
+ tappable: false,
@@ -1359,7 +1357,7 @@ steps:
13591357
+ child: Padding(
13601358
+ padding: const EdgeInsets.all(16.0),
13611359
+ child: Text(
1362-
+ question ?? "",
1360+
+ question ?? '',
13631361
+ style: Theme.of(context).textTheme.displaySmall,
13641362
+ ),
13651363
+ ),

animations/step_01/analysis_options.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
include: package:flutter_lints/flutter.yaml
1+
include: ../../analysis_options.yaml
22

33
analyzer:
44
errors:

0 commit comments

Comments
 (0)