Skip to content

Commit d21ac4c

Browse files
author
Kamil Klyta
committed
Migrate example app
1 parent c4e146d commit d21ac4c

14 files changed

+92
-207
lines changed

example/lib/indicators/check_mark_indicator.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ class CheckMarkIndicator extends StatefulWidget {
66
final Widget child;
77

88
const CheckMarkIndicator({
9-
Key key,
10-
@required this.child,
9+
Key? key,
10+
required this.child,
1111
}) : super(key: key);
1212

1313
@override
@@ -37,7 +37,7 @@ class _CheckMarkIndicatorState extends State<CheckMarkIndicator>
3737
children: <Widget>[
3838
AnimatedBuilder(
3939
animation: controller,
40-
builder: (BuildContext context, Widget _) {
40+
builder: (BuildContext context, Widget? _) {
4141
/// set [_renderCompleteState] to true when controller.state become completed
4242
if (controller.didStateChange(to: IndicatorState.complete)) {
4343
_renderCompleteState = true;
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import 'package:custom_refresh_indicator/custom_refresh_indicator.dart';
2-
import 'package:flutter/foundation.dart';
32

43
class CustomIndicatorConfig {
54
final IndicatorBuilder builder;
65

76
const CustomIndicatorConfig({
8-
@required this.builder,
9-
}) : assert(builder != null, 'builder argument cannot be null');
7+
required this.builder,
8+
});
109
}

example/lib/indicators/emoji_indicator.dart

Lines changed: 0 additions & 93 deletions
This file was deleted.

example/lib/indicators/ice_cream_indicator.dart

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import 'package:flutter/material.dart';
33
import 'package:flutter/widgets.dart';
44

55
class ParalaxConfig {
6-
final int level;
7-
final AssetImage image;
6+
final int? level;
7+
final AssetImage? image;
88

99
const ParalaxConfig({
1010
this.level,
@@ -16,8 +16,8 @@ class IceCreamIndicator extends StatefulWidget {
1616
final Widget child;
1717

1818
const IceCreamIndicator({
19-
Key key,
20-
@required this.child,
19+
Key? key,
20+
required this.child,
2121
}) : super(key: key);
2222

2323
@override
@@ -60,8 +60,8 @@ class _IceCreamIndicatorState extends State<IceCreamIndicator>
6060
static const _indicatorSize = 150.0;
6161
static const _imageSize = 140.0;
6262

63-
IndicatorState _prevState;
64-
AnimationController _spoonController;
63+
IndicatorState? _prevState;
64+
late AnimationController _spoonController;
6565
static final _spoonTween = CurveTween(curve: Curves.easeInOut);
6666

6767
@override
@@ -75,13 +75,13 @@ class _IceCreamIndicatorState extends State<IceCreamIndicator>
7575
return Transform.translate(
7676
offset: Offset(
7777
0,
78-
-(asset.level * (controller.value.clamp(1.0, 1.5) - 1.0) * 20) + 10,
78+
-(asset.level! * (controller.value.clamp(1.0, 1.5) - 1.0) * 20) + 10,
7979
),
8080
child: OverflowBox(
8181
maxHeight: _imageSize,
8282
minHeight: _imageSize,
8383
child: Image(
84-
image: asset.image,
84+
image: asset.image!,
8585
fit: BoxFit.contain,
8686
height: _imageSize,
8787
),
@@ -104,7 +104,7 @@ class _IceCreamIndicatorState extends State<IceCreamIndicator>
104104
children: <Widget>[
105105
AnimatedBuilder(
106106
animation: controller,
107-
builder: (BuildContext context, Widget _) {
107+
builder: (BuildContext context, Widget? _) {
108108
final currentState = controller.state;
109109
if (_prevState == IndicatorState.armed &&
110110
currentState == IndicatorState.loading) {
@@ -114,7 +114,7 @@ class _IceCreamIndicatorState extends State<IceCreamIndicator>
114114
_spoonController.stop();
115115
} else if (currentState == IndicatorState.idle &&
116116
_prevState != currentState) {
117-
_spoonController..value = 0.0;
117+
_spoonController.value = 0.0;
118118
}
119119

120120
_prevState = currentState;

example/lib/indicators/plane_indicator.dart

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ class _Cloud {
1313
"assets/plane_indicator/cloud4.png",
1414
];
1515

16-
AnimationController controller;
17-
final Color color;
18-
final AssetImage image;
19-
final double width;
20-
final double dy;
21-
final double initialValue;
22-
final Duration duration;
16+
AnimationController? controller;
17+
final Color? color;
18+
final AssetImage? image;
19+
final double? width;
20+
final double? dy;
21+
final double? initialValue;
22+
final Duration? duration;
2323
_Cloud({
2424
this.color,
2525
this.image,
@@ -33,7 +33,7 @@ class _Cloud {
3333
class PlaneIndicator extends StatefulWidget {
3434
final Widget child;
3535
const PlaneIndicator({
36-
@required this.child,
36+
required this.child,
3737
});
3838

3939
@override
@@ -43,8 +43,8 @@ class PlaneIndicator extends StatefulWidget {
4343
class _PlaneIndicatorState extends State<PlaneIndicator>
4444
with TickerProviderStateMixin {
4545
static final _planeTween = CurveTween(curve: Curves.easeInOut);
46-
AnimationController _planeController;
47-
IndicatorState _prevState;
46+
late AnimationController _planeController;
47+
IndicatorState? _prevState;
4848

4949
@override
5050
void initState() {
@@ -120,15 +120,15 @@ class _PlaneIndicatorState extends State<PlaneIndicator>
120120
}
121121

122122
void _stopCloudAnimation() {
123-
for (final cloud in _clouds) cloud.controller..stop();
123+
for (final cloud in _clouds) cloud.controller!.stop();
124124
}
125125

126126
void _startCloudAnimation() {
127-
for (final cloud in _clouds) cloud.controller.repeat();
127+
for (final cloud in _clouds) cloud.controller!.repeat();
128128
}
129129

130130
void _disposeCloudsControllers() {
131-
for (final cloud in _clouds) cloud.controller.dispose();
131+
for (final cloud in _clouds) cloud.controller!.dispose();
132132
}
133133

134134
@override
@@ -151,7 +151,7 @@ class _PlaneIndicatorState extends State<PlaneIndicator>
151151
height: 50,
152152
fit: BoxFit.contain,
153153
),
154-
builder: (BuildContext context, Widget child) {
154+
builder: (BuildContext context, Widget? child) {
155155
return Transform.translate(
156156
offset: Offset(
157157
0.0, 10 * (0.5 - _planeTween.transform(_planeController.value))),
@@ -185,26 +185,26 @@ class _PlaneIndicatorState extends State<PlaneIndicator>
185185
_prevState = currentState;
186186

187187
return Stack(
188-
overflow: Overflow.clip,
188+
clipBehavior: Clip.hardEdge,
189189
children: <Widget>[
190190
if (_prevState != IndicatorState.idle)
191191
Container(
192192
height: _offsetToArmed * controller.value,
193193
color: Color(0xFFFDFEFF),
194194
width: double.infinity,
195195
child: AnimatedBuilder(
196-
animation: _clouds.first.controller,
197-
builder: (BuildContext context, Widget child) {
196+
animation: _clouds.first.controller!,
197+
builder: (BuildContext context, Widget? child) {
198198
return Stack(
199-
overflow: Overflow.clip,
199+
clipBehavior: Clip.hardEdge,
200200
children: <Widget>[
201201
for (final cloud in _clouds)
202202
Transform.translate(
203203
offset: Offset(
204-
((screenWidth + cloud.width) *
205-
cloud.controller.value) -
206-
cloud.width,
207-
cloud.dy * controller.value,
204+
((screenWidth + cloud.width!) *
205+
cloud.controller!.value) -
206+
cloud.width!,
207+
cloud.dy! * controller.value,
208208
),
209209
child: OverflowBox(
210210
minWidth: cloud.width,
@@ -215,7 +215,7 @@ class _PlaneIndicatorState extends State<PlaneIndicator>
215215
child: Container(
216216
child: Image(
217217
color: cloud.color,
218-
image: cloud.image,
218+
image: cloud.image!,
219219
fit: BoxFit.contain,
220220
),
221221
),

example/lib/indicators/simple_indicator.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ import 'custom_indicator.dart';
66

77
class SimpleIndicatorContent extends StatelessWidget {
88
const SimpleIndicatorContent({
9-
@required this.controller,
9+
required this.controller,
1010
this.indicatorSize = _defaultIndicatorSize,
11-
}) : assert(indicatorSize != null && indicatorSize > 0);
11+
}) : assert(indicatorSize > 0);
1212

1313
final IndicatorController controller;
1414
static const _defaultIndicatorSize = 40.0;

example/lib/main.dart

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

4-
import 'indicators/emoji_indicator.dart';
54
import 'indicators/simple_indicator.dart';
65
import 'screens/example_indicator_screen.dart';
76
import 'screens/ice_cream_indicator_screen.dart';
@@ -41,7 +40,7 @@ class MainScreen extends StatelessWidget {
4140
child: ListView(
4241
padding: const EdgeInsets.all(15),
4342
children: <Widget>[
44-
RaisedButton(
43+
ElevatedButton(
4544
child: Container(
4645
height: 50,
4746
alignment: Alignment.center,
@@ -53,7 +52,7 @@ class MainScreen extends StatelessWidget {
5352
),
5453
),
5554
const SizedBox(height: 15),
56-
RaisedButton(
55+
ElevatedButton(
5756
child: Container(
5857
height: 50,
5958
alignment: Alignment.center,
@@ -66,7 +65,7 @@ class MainScreen extends StatelessWidget {
6665
),
6766
),
6867
const SizedBox(height: 15),
69-
RaisedButton(
68+
ElevatedButton(
7069
child: Container(
7170
height: 50,
7271
alignment: Alignment.center,
@@ -79,7 +78,7 @@ class MainScreen extends StatelessWidget {
7978
),
8079
),
8180
const SizedBox(height: 15),
82-
RaisedButton(
81+
ElevatedButton(
8382
child: Container(
8483
height: 50,
8584
alignment: Alignment.center,
@@ -91,7 +90,7 @@ class MainScreen extends StatelessWidget {
9190
),
9291
),
9392
const SizedBox(height: 15),
94-
RaisedButton(
93+
ElevatedButton(
9594
child: Container(
9695
height: 50,
9796
alignment: Alignment.center,
@@ -103,7 +102,7 @@ class MainScreen extends StatelessWidget {
103102
),
104103
),
105104
const SizedBox(height: 15),
106-
RaisedButton(
105+
ElevatedButton(
107106
child: Container(
108107
height: 50,
109108
alignment: Alignment.center,
@@ -115,18 +114,6 @@ class MainScreen extends StatelessWidget {
115114
),
116115
),
117116
const SizedBox(height: 15),
118-
RaisedButton(
119-
child: Container(
120-
height: 50,
121-
alignment: Alignment.center,
122-
child: Text("Emoji"),
123-
),
124-
onPressed: () => Navigator.pushNamed(
125-
context,
126-
'/example',
127-
arguments: emojiIndicator,
128-
),
129-
),
130117
],
131118
),
132119
),

0 commit comments

Comments
 (0)