Skip to content

Commit dc68b62

Browse files
author
Gordon Hayes
committed
refactor: analysis
1 parent 57a7730 commit dc68b62

10 files changed

+88
-140
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
include: package:very_good_analysis/analysis_options.yaml
2+
3+
analyzer:
4+
strong-mode:
5+
implicit-casts: false
6+
implicit-dynamic: false
7+
8+
linter:
9+
rules:
10+
public_member_api_docs: false

section_2/built_in_explicit_animations/lib/main.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,25 @@ import 'package:transition_widgets_example/transitions.dart/rotate_and_scale_tra
66
import 'package:transition_widgets_example/transitions.dart/scale_transition.dart';
77
import 'package:transition_widgets_example/transitions.dart/slide_transition.dart';
88

9-
void main() => runApp(MyApp());
9+
void main() => runApp(const MyApp());
1010

1111
class MyApp extends StatelessWidget {
12+
const MyApp({Key key}) : super(key: key);
13+
1214
@override
1315
Widget build(BuildContext context) {
1416
return MaterialApp(
1517
title: 'Transition Examples',
1618
theme: theme,
1719
home: Scaffold(
1820
appBar: AppBar(
19-
title: Text('Transitions'),
21+
title: const Text('Transitions'),
2022
),
2123
body: Center(
2224
child: SlideTransitionExample(
2325
child: Column(
2426
mainAxisAlignment: MainAxisAlignment.spaceAround,
25-
children: <Widget>[
27+
children: const <Widget>[
2628
AlignTransitionExample(),
2729
RotateAndScaleTransitionExample(),
2830
FadeTransitionExample(),

section_2/built_in_explicit_animations/lib/transitions.dart/align_transition.dart

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
22
import 'package:transition_widgets_example/styles.dart';
33

44
class AlignTransitionExample extends StatefulWidget {
5-
AlignTransitionExample({Key key}) : super(key: key);
5+
const AlignTransitionExample({Key key}) : super(key: key);
66

77
@override
88
_AlignTransitionExampleState createState() => _AlignTransitionExampleState();
@@ -17,7 +17,7 @@ class _AlignTransitionExampleState extends State<AlignTransitionExample>
1717
void initState() {
1818
_controller = AnimationController(
1919
vsync: this,
20-
duration: Duration(seconds: 2),
20+
duration: const Duration(seconds: 2),
2121
);
2222
_animation = Tween<AlignmentGeometry>(
2323
begin: Alignment.topLeft, end: Alignment.topRight)
@@ -38,10 +38,16 @@ class _AlignTransitionExampleState extends State<AlignTransitionExample>
3838
return AlignTransition(
3939
alignment: _animation,
4040
child: Container(
41-
color: salmon,
42-
width: 100,
43-
height: 100,
44-
child: Center(child: Text('Align', style: TextStyle(fontSize: 24)))),
41+
color: salmon,
42+
width: 100,
43+
height: 100,
44+
child: const Center(
45+
child: Text(
46+
'Align',
47+
style: TextStyle(fontSize: 24),
48+
),
49+
),
50+
),
4551
);
4652
}
4753
}

section_2/built_in_explicit_animations/lib/transitions.dart/fade_transition.dart

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'package:flutter/material.dart';
22

33
class FadeTransitionExample extends StatefulWidget {
4-
FadeTransitionExample({Key key}) : super(key: key);
4+
const FadeTransitionExample({Key key}) : super(key: key);
55

66
@override
77
_FadeTransitionExampleState createState() => _FadeTransitionExampleState();
@@ -17,9 +17,10 @@ class _FadeTransitionExampleState extends State<FadeTransitionExample>
1717
@override
1818
void initState() {
1919
_controller =
20-
AnimationController(vsync: this, duration: Duration(seconds: 5));
21-
_controller.repeat(reverse: true);
22-
_controller.addStatusListener(_animationStatusListener);
20+
AnimationController(vsync: this, duration: const Duration(seconds: 5));
21+
_controller
22+
..repeat(reverse: true)
23+
..addStatusListener(_animationStatusListener);
2324
super.initState();
2425
}
2526

@@ -51,15 +52,17 @@ class _FadeTransitionExampleState extends State<FadeTransitionExample>
5152
duration: const Duration(milliseconds: 300),
5253
transitionBuilder: (Widget child, Animation<double> animation) {
5354
return SlideTransition(
55+
position: Tween<Offset>(
56+
begin: const Offset(1, 0),
57+
end: const Offset(0.0, 0),
58+
).animate(animation),
5459
child: child,
55-
position: Tween<Offset>(begin: Offset(1, 0), end: Offset(0.0, 0))
56-
.animate(animation),
5760
);
5861
},
5962
child: Text(
6063
_text,
6164
key: ValueKey<String>(_key),
62-
style: Theme.of(context).textTheme.headline,
65+
style: Theme.of(context).textTheme.headline5,
6366
),
6467
),
6568
);

section_2/built_in_explicit_animations/lib/transitions.dart/rotate_and_scale_transition.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
22
import 'package:transition_widgets_example/styles.dart';
33

44
class RotateAndScaleTransitionExample extends StatefulWidget {
5-
RotateAndScaleTransitionExample({Key key}) : super(key: key);
5+
const RotateAndScaleTransitionExample({Key key}) : super(key: key);
66

77
@override
88
_RotateAndScaleTransitionExampleState createState() =>
@@ -21,11 +21,11 @@ class _RotateAndScaleTransitionExampleState
2121
void initState() {
2222
_controller = AnimationController(
2323
vsync: this,
24-
duration: Duration(seconds: 3),
24+
duration: const Duration(seconds: 3),
2525
);
2626
_controller2 = AnimationController(
2727
vsync: this,
28-
duration: Duration(seconds: 3),
28+
duration: const Duration(seconds: 3),
2929
);
3030
_rotateAnimation = Tween<double>(begin: 0, end: 1).animate(
3131
CurvedAnimation(parent: _controller, curve: Curves.elasticOut));
@@ -52,7 +52,7 @@ class _RotateAndScaleTransitionExampleState
5252
color: mustard,
5353
width: 100,
5454
height: 100,
55-
child: Center(
55+
child: const Center(
5656
child: Text('Rotate', style: TextStyle(fontSize: 24)),
5757
)),
5858
),

section_2/built_in_explicit_animations/lib/transitions.dart/scale_transition.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ import 'package:flutter_hooks/flutter_hooks.dart';
33
import 'package:transition_widgets_example/styles.dart';
44

55
class ScaleTransitionExample extends HookWidget {
6+
const ScaleTransitionExample({Key key}) : super(key: key);
7+
68
@override
79
Widget build(BuildContext context) {
810
final _controller = useAnimationController(
9-
duration: Duration(seconds: 1),
11+
duration: const Duration(seconds: 1),
1012
lowerBound: 0,
1113
upperBound: 1,
1214
);
@@ -31,7 +33,7 @@ class ScaleTransitionExample extends HookWidget {
3133
color: sunset,
3234
width: 100,
3335
height: 100,
34-
child: Center(
36+
child: const Center(
3537
child: Text(
3638
'Scale',
3739
style: TextStyle(fontSize: 24),

section_2/built_in_explicit_animations/lib/transitions.dart/slide_transition.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import 'package:flutter/material.dart';
22

33
class SlideTransitionExample extends StatefulWidget {
4-
SlideTransitionExample({Key key, this.child}) : super(key: key);
4+
const SlideTransitionExample({Key key, this.child}) : super(key: key);
55

66
final Widget child;
77

@@ -18,11 +18,11 @@ class _SlideTransitionExampleState extends State<SlideTransitionExample>
1818
void initState() {
1919
_controller = AnimationController(
2020
vsync: this,
21-
duration: Duration(seconds: 1),
21+
duration: const Duration(seconds: 1),
2222
);
2323
_animation = Tween<Offset>(
24-
begin: Offset(0, 1),
25-
end: Offset(0, 0),
24+
begin: const Offset(0, 1),
25+
end: const Offset(0, 0),
2626
).animate(
2727
CurvedAnimation(
2828
parent: _controller,

0 commit comments

Comments
 (0)