Skip to content

Commit 63d50a4

Browse files
committed
Use the flutter lints package for analysis
1 parent 6fd707e commit 63d50a4

22 files changed

+165
-113
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- Added `onStateChanged` function argument that allows tracking indicator state changes.
1313
- The `IndicatorStateHelper` class is now deprecated in favor of `onStateChange` function and `IndicatorStateChange` class.
1414
- Initial support for programmatically-controlled indicators has been added. Added the `show`,` hide` and `refresh` methods to the` CustomRefreshIndicatorState` class. It can be accessed via GlobalKey. Take a look at an [programmatically-controlled screen example](/example/lib/screens/programmatically_controlled_indicator_screen.dart).
15+
- Use the `flutter_lints` package for analysis.
1516

1617
## 1.0.0
1718

example/lib/indicators/check_mark_indicator.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class _CheckMarkIndicatorState extends State<CheckMarkIndicator>
8686
child: CircularProgressIndicator(
8787
strokeWidth: 2,
8888
valueColor:
89-
AlwaysStoppedAnimation(Colors.white),
89+
const AlwaysStoppedAnimation(Colors.white),
9090
value:
9191
controller.isDragging || controller.isArmed
9292
? controller.value.clamp(0.0, 1.0)

example/lib/indicators/plane_indicator.dart

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ class _Cloud {
3333
class PlaneIndicator extends StatefulWidget {
3434
final Widget child;
3535
const PlaneIndicator({
36+
Key? key,
3637
required this.child,
37-
});
38+
}) : super(key: key);
3839

3940
@override
4041
_PlaneIndicatorState createState() => _PlaneIndicatorState();
@@ -64,49 +65,50 @@ class _PlaneIndicatorState extends State<PlaneIndicator>
6465
dy: 10.0,
6566
image: AssetImage(_Cloud._assets[1]),
6667
width: 100,
67-
duration: Duration(milliseconds: 1600),
68+
duration: const Duration(milliseconds: 1600),
6869
),
6970
_Cloud(
7071
color: _Cloud._light,
7172
initialValue: 0.15,
7273
dy: 25.0,
7374
image: AssetImage(_Cloud._assets[3]),
7475
width: 40,
75-
duration: Duration(milliseconds: 1600),
76+
duration: const Duration(milliseconds: 1600),
7677
),
7778
_Cloud(
7879
color: _Cloud._light,
7980
initialValue: 0.3,
8081
dy: 65.0,
8182
image: AssetImage(_Cloud._assets[2]),
8283
width: 60,
83-
duration: Duration(milliseconds: 1600),
84+
duration: const Duration(milliseconds: 1600),
8485
),
8586
_Cloud(
8687
color: _Cloud._dark,
8788
initialValue: 0.8,
8889
dy: 70.0,
8990
image: AssetImage(_Cloud._assets[3]),
9091
width: 100,
91-
duration: Duration(milliseconds: 1600),
92+
duration: const Duration(milliseconds: 1600),
9293
),
9394
_Cloud(
9495
color: _Cloud._normal,
9596
initialValue: 0.0,
9697
dy: 10,
9798
image: AssetImage(_Cloud._assets[0]),
9899
width: 80,
99-
duration: Duration(milliseconds: 1600),
100+
duration: const Duration(milliseconds: 1600),
100101
),
101102
];
102103

103104
void _setupCloudsAnimationControllers() {
104-
for (final cloud in _clouds)
105+
for (final cloud in _clouds) {
105106
cloud.controller = AnimationController(
106107
vsync: this,
107108
duration: cloud.duration,
108109
value: cloud.initialValue,
109110
);
111+
}
110112
}
111113

112114
void _startPlaneAnimation() {
@@ -116,19 +118,25 @@ class _PlaneIndicatorState extends State<PlaneIndicator>
116118
void _stopPlaneAnimation() {
117119
_planeController
118120
..stop()
119-
..animateTo(0.0, duration: Duration(milliseconds: 100));
121+
..animateTo(0.0, duration: const Duration(milliseconds: 100));
120122
}
121123

122124
void _stopCloudAnimation() {
123-
for (final cloud in _clouds) cloud.controller!.stop();
125+
for (final cloud in _clouds) {
126+
cloud.controller!.stop();
127+
}
124128
}
125129

126130
void _startCloudAnimation() {
127-
for (final cloud in _clouds) cloud.controller!.repeat();
131+
for (final cloud in _clouds) {
132+
cloud.controller!.repeat();
133+
}
128134
}
129135

130136
void _disposeCloudsControllers() {
131-
for (final cloud in _clouds) cloud.controller!.dispose();
137+
for (final cloud in _clouds) {
138+
cloud.controller!.dispose();
139+
}
132140
}
133141

134142
@override
@@ -190,7 +198,7 @@ class _PlaneIndicatorState extends State<PlaneIndicator>
190198
if (_prevState != IndicatorState.idle)
191199
Container(
192200
height: _offsetToArmed * controller.value,
193-
color: Color(0xFFFDFEFF),
201+
color: const Color(0xFFFDFEFF),
194202
width: double.infinity,
195203
child: AnimatedBuilder(
196204
animation: _clouds.first.controller!,
@@ -212,12 +220,10 @@ class _PlaneIndicatorState extends State<PlaneIndicator>
212220
maxHeight: cloud.width,
213221
maxWidth: cloud.width,
214222
alignment: Alignment.topLeft,
215-
child: Container(
216-
child: Image(
217-
color: cloud.color,
218-
image: cloud.image!,
219-
fit: BoxFit.contain,
220-
),
223+
child: Image(
224+
color: cloud.color,
225+
image: cloud.image!,
226+
fit: BoxFit.contain,
221227
),
222228
),
223229
),

example/lib/indicators/simple_indicator.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@ import 'custom_indicator.dart';
66

77
class SimpleIndicatorContent extends StatelessWidget {
88
const SimpleIndicatorContent({
9+
Key? key,
910
required this.controller,
1011
this.indicatorSize = _defaultIndicatorSize,
11-
}) : assert(indicatorSize > 0);
12+
}) : assert(indicatorSize > 0),
13+
super(key: key);
1214

1315
final IndicatorController controller;
1416
static const _defaultIndicatorSize = 40.0;

example/lib/indicators/warp_indicator.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ class _WarpIndicatorState extends State<WarpIndicator>
4646
WarpAnimationState _state = WarpAnimationState.stopped;
4747

4848
List<Star> stars = [];
49-
var _offsetTween = Tween<Offset>(
49+
final _offsetTween = Tween<Offset>(
5050
begin: Offset.zero,
5151
end: Offset.zero,
5252
);
53-
var _angleTween = Tween<double>(
53+
final _angleTween = Tween<double>(
5454
begin: 0,
5555
end: 0,
5656
);
@@ -64,7 +64,7 @@ class _WarpIndicatorState extends State<WarpIndicator>
6464
void initState() {
6565
shakeController = AnimationController(
6666
vsync: this,
67-
duration: Duration(milliseconds: 100),
67+
duration: const Duration(milliseconds: 100),
6868
);
6969
super.initState();
7070
}
@@ -150,7 +150,7 @@ class _WarpIndicatorState extends State<WarpIndicator>
150150
stars: stars,
151151
color: widget.skyColor,
152152
),
153-
child: SizedBox.expand(),
153+
child: const SizedBox.expand(),
154154
);
155155
},
156156
);
@@ -216,8 +216,8 @@ class Star {
216216
final random = Random();
217217
angle = random.nextDouble() * pi * 3;
218218
speed = Offset(cos(angle), sin(angle));
219-
final minSpeedScale = 20;
220-
final maxSpeedScale = 35;
219+
const minSpeedScale = 20;
220+
const maxSpeedScale = 35;
221221
final speedScale = minSpeedScale +
222222
random.nextInt(maxSpeedScale - minSpeedScale).toDouble();
223223
speed = speed.scale(
@@ -292,7 +292,7 @@ class Sky extends CustomPainter {
292292
return [
293293
CustomPainterSemantics(
294294
rect: rect,
295-
properties: SemanticsProperties(
295+
properties: const SemanticsProperties(
296296
label: 'Lightspeed animation.',
297297
textDirection: TextDirection.ltr,
298298
),

example/lib/main.dart

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ import 'screens/check_mark_indicator_screen.dart';
1111
import 'screens/warp_indicator_screen.dart';
1212
import 'utils/mobile_like_scroll_behavior.dart';
1313

14-
void main() => runApp(MyApp());
14+
void main() => runApp(const MyApp());
1515

1616
class MyApp extends StatelessWidget {
17+
const MyApp({Key? key}) : super(key: key);
18+
1719
@override
1820
Widget build(BuildContext context) {
1921
return MaterialApp(
@@ -22,28 +24,30 @@ class MyApp extends StatelessWidget {
2224
theme: ThemeData(
2325
primarySwatch: Colors.blue,
2426
),
25-
home: MainScreen(),
27+
home: const MainScreen(),
2628
builder: (context, child) => WebFrame(child: child),
2729
routes: {
28-
'/example': (context) => ExampleIndicatorScreen(),
29-
'/plane': (context) => PlaneIndicatorScreen(),
30-
'/ice_cream': (context) => IceCreamIndicatorScreen(),
31-
'/presentation': (context) => PresentationScreen(),
32-
'/check-mark': (context) => CheckMarkIndicatorScreen(),
33-
'/warp': (context) => WarpIndicatorScreen(),
30+
'/example': (context) => const ExampleIndicatorScreen(),
31+
'/plane': (context) => const PlaneIndicatorScreen(),
32+
'/ice_cream': (context) => const IceCreamIndicatorScreen(),
33+
'/presentation': (context) => const PresentationScreen(),
34+
'/check-mark': (context) => const CheckMarkIndicatorScreen(),
35+
'/warp': (context) => const WarpIndicatorScreen(),
3436
'/programmatically-controlled': (context) =>
35-
ProgrammaticallyControlled(),
37+
const ProgrammaticallyControlled(),
3638
},
3739
);
3840
}
3941
}
4042

4143
class MainScreen extends StatelessWidget {
44+
const MainScreen({Key? key}) : super(key: key);
45+
4246
@override
4347
Widget build(BuildContext context) {
4448
return Scaffold(
4549
appBar: AppBar(
46-
title: Text("Examples"),
50+
title: const Text("Examples"),
4751
),
4852
body: SafeArea(
4953
child: ListView(
@@ -53,7 +57,7 @@ class MainScreen extends StatelessWidget {
5357
child: Container(
5458
height: 50,
5559
alignment: Alignment.center,
56-
child: Text("Presentation"),
60+
child: const Text("Presentation"),
5761
),
5862
onPressed: () => Navigator.pushNamed(
5963
context,
@@ -65,7 +69,7 @@ class MainScreen extends StatelessWidget {
6569
child: Container(
6670
height: 50,
6771
alignment: Alignment.center,
68-
child: Text("Simple"),
72+
child: const Text("Simple"),
6973
),
7074
onPressed: () => Navigator.pushNamed(
7175
context,
@@ -78,7 +82,7 @@ class MainScreen extends StatelessWidget {
7882
child: Container(
7983
height: 50,
8084
alignment: Alignment.center,
81-
child: Text("Simple with list opacity"),
85+
child: const Text("Simple with list opacity"),
8286
),
8387
onPressed: () => Navigator.pushNamed(
8488
context,
@@ -91,7 +95,7 @@ class MainScreen extends StatelessWidget {
9195
child: Container(
9296
height: 50,
9397
alignment: Alignment.center,
94-
child: Text("Plane"),
98+
child: const Text("Plane"),
9599
),
96100
onPressed: () => Navigator.pushNamed(
97101
context,
@@ -103,7 +107,7 @@ class MainScreen extends StatelessWidget {
103107
child: Container(
104108
height: 50,
105109
alignment: Alignment.center,
106-
child: Text("Ice cream"),
110+
child: const Text("Ice cream"),
107111
),
108112
onPressed: () => Navigator.pushNamed(
109113
context,
@@ -115,7 +119,7 @@ class MainScreen extends StatelessWidget {
115119
child: Container(
116120
height: 50,
117121
alignment: Alignment.center,
118-
child: Text("Check mark"),
122+
child: const Text("Check mark"),
119123
),
120124
onPressed: () => Navigator.pushNamed(
121125
context,
@@ -127,7 +131,7 @@ class MainScreen extends StatelessWidget {
127131
child: Container(
128132
height: 50,
129133
alignment: Alignment.center,
130-
child: Text("Warp indicator"),
134+
child: const Text("Warp indicator"),
131135
),
132136
onPressed: () => Navigator.pushNamed(
133137
context,
@@ -140,7 +144,7 @@ class MainScreen extends StatelessWidget {
140144
child: Container(
141145
height: 50,
142146
alignment: Alignment.center,
143-
child: Text("Programmatically-controlled warp"),
147+
child: const Text("Programmatically-controlled warp"),
144148
),
145149
onPressed: () => Navigator.pushNamed(
146150
context,

example/lib/screens/check_mark_indicator_screen.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import 'package:example/widgets/example_list.dart';
44
import 'package:flutter/material.dart';
55

66
class CheckMarkIndicatorScreen extends StatefulWidget {
7+
const CheckMarkIndicatorScreen({Key? key}) : super(key: key);
8+
79
@override
810
_CheckMarkIndicatorScreenState createState() =>
911
_CheckMarkIndicatorScreenState();
@@ -12,12 +14,12 @@ class CheckMarkIndicatorScreen extends StatefulWidget {
1214
class _CheckMarkIndicatorScreenState extends State<CheckMarkIndicatorScreen> {
1315
@override
1416
Widget build(BuildContext context) {
15-
return Scaffold(
17+
return const Scaffold(
1618
backgroundColor: appBackgroundColor,
17-
appBar: const ExampleAppBar(),
19+
appBar: ExampleAppBar(),
1820
body: SafeArea(
1921
child: CheckMarkIndicator(
20-
child: const ExampleList(),
22+
child: ExampleList(),
2123
),
2224
),
2325
);

example/lib/screens/example_indicator_screen.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import 'package:example/widgets/example_list.dart';
55
import 'package:flutter/material.dart';
66

77
class ExampleIndicatorScreen extends StatelessWidget {
8+
const ExampleIndicatorScreen({Key? key}) : super(key: key);
9+
810
@override
911
Widget build(BuildContext context) {
1012
final CustomIndicatorConfig customIndicator =

example/lib/screens/ice_cream_indicator_screen.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import 'package:example/widgets/example_list.dart';
44
import 'package:flutter/material.dart';
55

66
class IceCreamIndicatorScreen extends StatefulWidget {
7+
const IceCreamIndicatorScreen({Key? key}) : super(key: key);
8+
79
@override
810
_IceCreamIndicatorScreenState createState() =>
911
_IceCreamIndicatorScreenState();
@@ -12,12 +14,12 @@ class IceCreamIndicatorScreen extends StatefulWidget {
1214
class _IceCreamIndicatorScreenState extends State<IceCreamIndicatorScreen> {
1315
@override
1416
Widget build(BuildContext context) {
15-
return Scaffold(
17+
return const Scaffold(
1618
backgroundColor: appBackgroundColor,
17-
appBar: const ExampleAppBar(),
19+
appBar: ExampleAppBar(),
1820
body: SafeArea(
1921
child: IceCreamIndicator(
20-
child: const ExampleList(),
22+
child: ExampleList(),
2123
),
2224
),
2325
);

0 commit comments

Comments
 (0)