Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ec0842e

Browse files
authoredDec 5, 2019
implicit-casts:false in examples (flutter#45805)
1 parent c6fe7bb commit ec0842e

40 files changed

+110
-107
lines changed
 

‎examples/catalog/lib/animated_list.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ class ListModel<E> {
122122
_items = initialItems?.toList() ?? <E>[];
123123

124124
final GlobalKey<AnimatedListState> listKey;
125-
final dynamic removedItemBuilder;
125+
final Widget Function(E item, BuildContext context, Animation<double> animation) removedItemBuilder;
126126
final List<E> _items;
127127

128128
AnimatedListState get _animatedList => listKey.currentState;

‎examples/flutter_gallery/lib/demo/animation/home.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class _RenderStatusBarPaddingSliver extends RenderSliver {
6464

6565
@override
6666
void performLayout() {
67-
final double height = (maxHeight - constraints.scrollOffset / scrollFactor).clamp(0.0, maxHeight);
67+
final double height = (maxHeight - constraints.scrollOffset / scrollFactor).clamp(0.0, maxHeight) as double;
6868
geometry = SliverGeometry(
6969
paintExtent: math.min(height, constraints.remainingPaintExtent),
7070
scrollExtent: maxHeight,
@@ -285,7 +285,7 @@ class _AllSectionsView extends AnimatedWidget {
285285
final List<Widget> sectionCards;
286286

287287
double _selectedIndexDelta(int index) {
288-
return (index.toDouble() - selectedIndex.value).abs().clamp(0.0, 1.0);
288+
return (index.toDouble() - selectedIndex.value).abs().clamp(0.0, 1.0) as double;
289289
}
290290

291291
Widget _build(BuildContext context, BoxConstraints constraints) {
@@ -498,7 +498,7 @@ class _AnimationDemoHomeState extends State<AnimationDemoHome> {
498498
return ListTile.divideTiles(context: context, tiles: detailItems);
499499
}
500500

501-
Iterable<Widget> _allHeadingItems(double maxHeight, double midScrollOffset) {
501+
List<Widget> _allHeadingItems(double maxHeight, double midScrollOffset) {
502502
final List<Widget> sectionCards = <Widget>[];
503503
for (int index = 0; index < allSections.length; index++) {
504504
sectionCards.add(LayoutId(

‎examples/flutter_gallery/lib/demo/animation/sections.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,8 @@ class Section {
4444

4545
@override
4646
bool operator==(Object other) {
47-
if (other is! Section)
48-
return false;
49-
final Section otherSection = other;
50-
return title == otherSection.title;
47+
return other is Section
48+
&& other.title == title;
5149
}
5250

5351
@override

‎examples/flutter_gallery/lib/demo/calculator/logic.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ class CalcExpression {
287287
// multiplication or division symbols.
288288
num currentTermValue = removeNextTerm(list);
289289
while (list.isNotEmpty) {
290-
final OperationToken opToken = list.removeAt(0);
290+
final OperationToken opToken = list.removeAt(0) as OperationToken;
291291
final num nextTermValue = removeNextTerm(list);
292292
switch (opToken.operation) {
293293
case Operation.Addition:
@@ -313,11 +313,11 @@ class CalcExpression {
313313
/// and division symbols.
314314
static num removeNextTerm(List<ExpressionToken> list) {
315315
assert(list != null && list.isNotEmpty);
316-
final NumberToken firstNumToken = list.removeAt(0);
316+
final NumberToken firstNumToken = list.removeAt(0) as NumberToken;
317317
num currentValue = firstNumToken.number;
318318
while (list.isNotEmpty) {
319319
bool isDivision = false;
320-
final OperationToken nextOpToken = list.first;
320+
final OperationToken nextOpToken = list.first as OperationToken;
321321
switch (nextOpToken.operation) {
322322
case Operation.Addition:
323323
case Operation.Subtraction:
@@ -331,7 +331,7 @@ class CalcExpression {
331331
// Remove the operation token.
332332
list.removeAt(0);
333333
// Remove the next number token.
334-
final NumberToken nextNumToken = list.removeAt(0);
334+
final NumberToken nextNumToken = list.removeAt(0) as NumberToken;
335335
final num nextNumber = nextNumToken.number;
336336
if (isDivision)
337337
currentValue /= nextNumber;

‎examples/flutter_gallery/lib/demo/cupertino/cupertino_navigation_demo.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,9 @@ class Tab1ItemPageState extends State<Tab1ItemPage> {
293293
final math.Random random = math.Random();
294294
return Color.fromARGB(
295295
255,
296-
(widget.color.red + random.nextInt(100) - 50).clamp(0, 255),
297-
(widget.color.green + random.nextInt(100) - 50).clamp(0, 255),
298-
(widget.color.blue + random.nextInt(100) - 50).clamp(0, 255),
296+
(widget.color.red + random.nextInt(100) - 50).clamp(0, 255) as int,
297+
(widget.color.green + random.nextInt(100) - 50).clamp(0, 255) as int,
298+
(widget.color.blue + random.nextInt(100) - 50).clamp(0, 255) as int,
299299
);
300300
});
301301
}
@@ -635,9 +635,9 @@ class Tab2ConversationAvatar extends StatelessWidget {
635635
color,
636636
Color.fromARGB(
637637
color.alpha,
638-
(color.red - 60).clamp(0, 255),
639-
(color.green - 60).clamp(0, 255),
640-
(color.blue - 60).clamp(0, 255),
638+
(color.red - 60).clamp(0, 255) as int,
639+
(color.green - 60).clamp(0, 255) as int,
640+
(color.blue - 60).clamp(0, 255) as int,
641641
),
642642
],
643643
),

‎examples/flutter_gallery/lib/demo/material/backdrop_demo.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,12 +205,12 @@ class BackdropPanel extends StatelessWidget {
205205
class BackdropTitle extends AnimatedWidget {
206206
const BackdropTitle({
207207
Key key,
208-
Listenable listenable,
208+
Animation<double> listenable,
209209
}) : super(key: key, listenable: listenable);
210210

211211
@override
212212
Widget build(BuildContext context) {
213-
final Animation<double> animation = listenable;
213+
final Animation<double> animation = listenable as Animation<double>;
214214
return DefaultTextStyle(
215215
style: Theme.of(context).primaryTextTheme.title,
216216
softWrap: false,
@@ -283,7 +283,7 @@ class _BackdropDemoState extends State<BackdropDemo> with SingleTickerProviderSt
283283
}
284284

285285
double get _backdropHeight {
286-
final RenderBox renderBox = _backdropKey.currentContext.findRenderObject();
286+
final RenderBox renderBox = _backdropKey.currentContext.findRenderObject() as RenderBox;
287287
return renderBox.size.height;
288288
}
289289

‎examples/flutter_gallery/lib/demo/material/grid_list_demo.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,10 @@ class _GridPhotoViewerState extends State<GridPhotoViewer> with SingleTickerProv
8787
Offset _clampOffset(Offset offset) {
8888
final Size size = context.size;
8989
final Offset minOffset = Offset(size.width, size.height) * (1.0 - _scale);
90-
return Offset(offset.dx.clamp(minOffset.dx, 0.0), offset.dy.clamp(minOffset.dy, 0.0));
90+
return Offset(
91+
offset.dx.clamp(minOffset.dx, 0.0) as double,
92+
offset.dy.clamp(minOffset.dy, 0.0) as double,
93+
);
9194
}
9295

9396
void _handleFlingAnimation() {
@@ -107,7 +110,7 @@ class _GridPhotoViewerState extends State<GridPhotoViewer> with SingleTickerProv
107110

108111
void _handleOnScaleUpdate(ScaleUpdateDetails details) {
109112
setState(() {
110-
_scale = (_previousScale * details.scale).clamp(1.0, 4.0);
113+
_scale = (_previousScale * details.scale).clamp(1.0, 4.0) as double;
111114
// Ensure that image location under the focal point stays in the same place despite scaling.
112115
_offset = _clampOffset(details.focalPoint - _normalizedOffset * _scale);
113116
});

‎examples/flutter_gallery/lib/demo/material/page_selector_demo.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class _PageSelector extends StatelessWidget {
1414
void _handleArrowButtonPress(BuildContext context, int delta) {
1515
final TabController controller = DefaultTabController.of(context);
1616
if (!controller.indexIsChanging)
17-
controller.animateTo((controller.index + delta).clamp(0, icons.length - 1));
17+
controller.animateTo((controller.index + delta).clamp(0, icons.length - 1) as int);
1818
}
1919

2020
@override

‎examples/flutter_gallery/lib/demo/material/slider_demo.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ class _SlidersState extends State<_Sliders> {
257257
final double newValue = double.tryParse(value);
258258
if (newValue != null && newValue != _continuousValue) {
259259
setState(() {
260-
_continuousValue = newValue.clamp(0, 100);
260+
_continuousValue = newValue.clamp(0.0, 100.0) as double;
261261
});
262262
}
263263
},

‎examples/flutter_gallery/lib/demo/pesto_demo.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class _RecipeGridPageState extends State<RecipeGridPage> {
129129
bottom: extraPadding,
130130
),
131131
child: Center(
132-
child: PestoLogo(height: logoHeight, t: t.clamp(0.0, 1.0)),
132+
child: PestoLogo(height: logoHeight, t: t.clamp(0.0, 1.0) as double),
133133
),
134134
);
135135
},

‎examples/flutter_gallery/lib/demo/shrine/backdrop.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,22 +111,22 @@ class _FrontLayer extends StatelessWidget {
111111
class _BackdropTitle extends AnimatedWidget {
112112
const _BackdropTitle({
113113
Key key,
114-
Listenable listenable,
114+
Animation<double> listenable,
115115
this.onPress,
116116
@required this.frontTitle,
117117
@required this.backTitle,
118118
}) : assert(frontTitle != null),
119119
assert(backTitle != null),
120120
super(key: key, listenable: listenable);
121121

122-
final Function onPress;
122+
final void Function() onPress;
123123
final Widget frontTitle;
124124
final Widget backTitle;
125125

126126
@override
127127
Widget build(BuildContext context) {
128128
final Animation<double> animation = CurvedAnimation(
129-
parent: listenable,
129+
parent: listenable as Animation<double>,
130130
curve: const Interval(0.0, 0.78),
131131
);
132132

‎examples/flutter_gallery/lib/demo/shrine/expanding_bottom_sheet.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ class _ListModel {
604604
_items = initialItems?.toList() ?? <int>[];
605605

606606
final GlobalKey<AnimatedListState> listKey;
607-
final dynamic removedItemBuilder;
607+
final Widget Function(int item, BuildContext context, Animation<double> animation) removedItemBuilder;
608608
final List<int> _items;
609609

610610
AnimatedListState get _animatedList => listKey.currentState;

‎examples/flutter_gallery/lib/demo/transformations/transformations_demo_board.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,9 @@ class BoardPoint {
270270
if (other.runtimeType != runtimeType) {
271271
return false;
272272
}
273-
final BoardPoint boardPoint = other;
274-
return boardPoint.q == q && boardPoint.r == r;
273+
return other is BoardPoint
274+
&& other.q == q
275+
&& other.r == r;
275276
}
276277

277278
@override

‎examples/flutter_gallery/lib/demo/transformations/transformations_demo_gesture_transformable.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ class _GestureTransformableState extends State<GestureTransformable> with Ticker
183183
// Get the offset of the current widget from the global screen coordinates.
184184
// TODO(justinmc): Protect against calling this during first build.
185185
static Offset getOffset(BuildContext context) {
186-
final RenderBox renderObject = context.findRenderObject();
186+
final RenderBox renderObject = context.findRenderObject() as RenderBox;
187187
return renderObject.localToGlobal(Offset.zero);
188188
}
189189

@@ -377,7 +377,7 @@ class _GestureTransformableState extends State<GestureTransformable> with Ticker
377377
final double clampedTotalScale = totalScale.clamp(
378378
widget.minScale,
379379
widget.maxScale,
380-
);
380+
) as double;
381381
final double clampedScale = clampedTotalScale / currentScale;
382382
return matrix..scale(clampedScale);
383383
}

‎examples/flutter_gallery/lib/demo/video_demo.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ class _ConnectivityOverlayState extends State<ConnectivityOverlay> {
280280
StreamSubscription<ConnectivityResult> connectivitySubscription;
281281
bool connected = true;
282282

283-
static const Widget errorSnackBar = SnackBar(
283+
static const SnackBar errorSnackBar = SnackBar(
284284
backgroundColor: Colors.red,
285285
content: ListTile(
286286
title: Text('No network'),

‎examples/flutter_gallery/lib/gallery/app.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ class _GalleryAppState extends State<GalleryApp> {
5353
// https://docs.flutter.io/flutter/widgets/Navigator-class.html
5454
return Map<String, WidgetBuilder>.fromIterable(
5555
kAllGalleryDemos,
56-
key: (dynamic demo) => '${demo.routeName}',
57-
value: (dynamic demo) => demo.buildRoute,
56+
key: (dynamic demo) => '${(demo as GalleryDemo).routeName}',
57+
value: (dynamic demo) => (demo as GalleryDemo).buildRoute,
5858
);
5959
}
6060

‎examples/flutter_gallery/lib/gallery/backdrop.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class _CrossFadeTransition extends AnimatedWidget {
9797

9898
@override
9999
Widget build(BuildContext context) {
100-
final Animation<double> progress = listenable;
100+
final Animation<double> progress = listenable as Animation<double>;
101101

102102
final double opacity1 = CurvedAnimation(
103103
parent: ReverseAnimation(progress),
@@ -227,7 +227,7 @@ class _BackdropState extends State<Backdrop> with SingleTickerProviderStateMixin
227227
double get _backdropHeight {
228228
// Warning: this can be safely called from the event handlers but it may
229229
// not be called at build time.
230-
final RenderBox renderBox = _backdropKey.currentContext.findRenderObject();
230+
final RenderBox renderBox = _backdropKey.currentContext.findRenderObject() as RenderBox;
231231
return math.max(0.0, renderBox.size.height - _kBackAppBarHeight - _kFrontClosedHeight);
232232
}
233233

‎examples/flutter_gallery/lib/gallery/demo.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ class ComponentDemoTabData {
3131
bool operator==(Object other) {
3232
if (other.runtimeType != runtimeType)
3333
return false;
34-
final ComponentDemoTabData typedOther = other;
35-
return typedOther.tabName == tabName
36-
&& typedOther.description == description
37-
&& typedOther.documentationUrl == documentationUrl;
34+
return other is ComponentDemoTabData
35+
&& other.tabName == tabName
36+
&& other.description == description
37+
&& other.documentationUrl == documentationUrl;
3838
}
3939

4040
@override

‎examples/flutter_gallery/lib/gallery/demos.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ class GalleryDemoCategory {
2222
return true;
2323
if (runtimeType != other.runtimeType)
2424
return false;
25-
final GalleryDemoCategory typedOther = other;
26-
return typedOther.name == name && typedOther.icon == icon;
25+
return other is GalleryDemoCategory
26+
&& other.name == name && other.icon == icon;
2727
}
2828

2929
@override
@@ -582,6 +582,6 @@ final Map<GalleryDemoCategory, List<GalleryDemo>> kGalleryCategoryToDemos =
582582
final Map<String, String> kDemoDocumentationUrl =
583583
Map<String, String>.fromIterable(
584584
kAllGalleryDemos.where((GalleryDemo demo) => demo.documentationUrl != null),
585-
key: (dynamic demo) => demo.routeName,
586-
value: (dynamic demo) => demo.documentationUrl,
585+
key: (dynamic demo) => (demo as GalleryDemo).routeName,
586+
value: (dynamic demo) => (demo as GalleryDemo).documentationUrl,
587587
);

‎examples/flutter_gallery/lib/gallery/home.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class _CategoriesPage extends StatelessWidget {
134134
crossAxisAlignment: CrossAxisAlignment.stretch,
135135
children: List<Widget>.generate(rowCount, (int rowIndex) {
136136
final int columnCountForRow = rowIndex == rowCount - 1
137-
? categories.length - columnCount * math.max(0, rowCount - 1)
137+
? categories.length - columnCount * math.max<int>(0, rowCount - 1)
138138
: columnCount;
139139

140140
return Row(

‎examples/flutter_gallery/lib/gallery/options.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ class GalleryOptions {
5454
bool operator ==(dynamic other) {
5555
if (runtimeType != other.runtimeType)
5656
return false;
57-
final GalleryOptions typedOther = other;
58-
return themeMode == typedOther.themeMode
59-
&& textScaleFactor == typedOther.textScaleFactor
60-
&& textDirection == typedOther.textDirection
61-
&& platform == typedOther.platform
62-
&& showPerformanceOverlay == typedOther.showPerformanceOverlay
63-
&& showRasterCacheImagesCheckerboard == typedOther.showRasterCacheImagesCheckerboard
64-
&& showOffscreenLayersCheckerboard == typedOther.showRasterCacheImagesCheckerboard;
57+
return other is GalleryOptions
58+
&& other.themeMode == themeMode
59+
&& other.textScaleFactor == textScaleFactor
60+
&& other.textDirection == textDirection
61+
&& other.platform == platform
62+
&& other.showPerformanceOverlay == showPerformanceOverlay
63+
&& other.showRasterCacheImagesCheckerboard == showRasterCacheImagesCheckerboard
64+
&& other.showOffscreenLayersCheckerboard == showRasterCacheImagesCheckerboard;
6565
}
6666

6767
@override

‎examples/flutter_gallery/lib/gallery/scales.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ class GalleryTextScaleValue {
1414
bool operator ==(dynamic other) {
1515
if (runtimeType != other.runtimeType)
1616
return false;
17-
final GalleryTextScaleValue typedOther = other;
18-
return scale == typedOther.scale && label == typedOther.label;
17+
return other is GalleryTextScaleValue
18+
&& other.scale == scale
19+
&& other.label == label;
1920
}
2021

2122
@override

‎examples/flutter_gallery/test/calculator/smoke_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'package:flutter_gallery/demo/calculator_demo.dart';
77
import 'package:flutter_test/flutter_test.dart';
88

99
void main() {
10-
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
10+
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized() as TestWidgetsFlutterBinding;
1111
if (binding is LiveTestWidgetsFlutterBinding)
1212
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
1313

‎examples/flutter_gallery/test/drawer_test.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import 'package:flutter_test/flutter_test.dart';
88
import 'package:flutter_gallery/gallery/app.dart';
99

1010
void main() {
11-
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
11+
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized() as TestWidgetsFlutterBinding;
1212
if (binding is LiveTestWidgetsFlutterBinding)
1313
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
1414

@@ -31,7 +31,7 @@ void main() {
3131
await tester.pumpAndSettle();
3232

3333
// Verify theme settings
34-
MaterialApp app = find.byType(MaterialApp).evaluate().first.widget;
34+
MaterialApp app = find.byType(MaterialApp).evaluate().first.widget as MaterialApp;
3535
expect(app.theme.brightness, equals(Brightness.light));
3636
expect(app.darkTheme.brightness, equals(Brightness.dark));
3737

@@ -40,23 +40,23 @@ void main() {
4040
await tester.pumpAndSettle();
4141
await tester.tap(find.text('Dark'));
4242
await tester.pumpAndSettle();
43-
app = find.byType(MaterialApp).evaluate().first.widget;
43+
app = find.byType(MaterialApp).evaluate().first.widget as MaterialApp;
4444
expect(app.themeMode, ThemeMode.dark);
4545

4646
// Switch to the light theme: first menu button, choose 'Light'
4747
await tester.tap(find.byIcon(Icons.arrow_drop_down).first);
4848
await tester.pumpAndSettle();
4949
await tester.tap(find.text('Light'));
5050
await tester.pumpAndSettle();
51-
app = find.byType(MaterialApp).evaluate().first.widget;
51+
app = find.byType(MaterialApp).evaluate().first.widget as MaterialApp;
5252
expect(app.themeMode, ThemeMode.light);
5353

5454
// Switch back to system theme setting: first menu button, choose 'System Default'
5555
await tester.tap(find.byIcon(Icons.arrow_drop_down).first);
5656
await tester.pumpAndSettle();
5757
await tester.tap(find.text('System Default').at(1));
5858
await tester.pumpAndSettle();
59-
app = find.byType(MaterialApp).evaluate().first.widget;
59+
app = find.byType(MaterialApp).evaluate().first.widget as MaterialApp;
6060
expect(app.themeMode, ThemeMode.system);
6161

6262
// Verify platform settings
@@ -67,7 +67,7 @@ void main() {
6767
await tester.pumpAndSettle();
6868
await tester.tap(find.text('Cupertino').at(1));
6969
await tester.pumpAndSettle();
70-
app = find.byType(MaterialApp).evaluate().first.widget;
70+
app = find.byType(MaterialApp).evaluate().first.widget as MaterialApp;
7171
expect(app.theme.platform, equals(TargetPlatform.iOS));
7272

7373
// Verify the font scale.

‎examples/flutter_gallery/test/example_code_display_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'package:flutter_gallery/gallery/app.dart';
77
import 'package:flutter_test/flutter_test.dart';
88

99
void main() {
10-
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
10+
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized() as TestWidgetsFlutterBinding;
1111
if (binding is LiveTestWidgetsFlutterBinding)
1212
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
1313

‎examples/flutter_gallery/test/pesto_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
77
import 'package:flutter_gallery/gallery/app.dart';
88

99
void main() {
10-
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
10+
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized() as TestWidgetsFlutterBinding;
1111
if (binding is LiveTestWidgetsFlutterBinding)
1212
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
1313

‎examples/flutter_gallery/test/simple_smoke_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
77
import 'package:flutter_gallery/gallery/app.dart' show GalleryApp;
88

99
void main() {
10-
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
10+
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized() as TestWidgetsFlutterBinding;
1111
if (binding is LiveTestWidgetsFlutterBinding)
1212
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
1313

‎examples/flutter_gallery/test/update_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Future<String> mockUpdateUrlFetcher() {
1111
}
1212

1313
void main() {
14-
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
14+
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized() as TestWidgetsFlutterBinding;
1515
if (binding is LiveTestWidgetsFlutterBinding)
1616
binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive;
1717

‎examples/flutter_gallery/test_driver/transitions_perf_test.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// found in the LICENSE file.
44

55
import 'dart:async';
6-
import 'dart:convert' show JsonEncoder, JsonDecoder;
6+
import 'dart:convert' show JsonEncoder, json;
77

88
import 'package:file/file.dart';
99
import 'package:file/local.dart';
@@ -69,14 +69,14 @@ Future<void> saveDurationsHistogram(List<Map<String, dynamic>> events, String ou
6969

7070
// Save the duration of the first frame after each 'Start Transition' event.
7171
for (Map<String, dynamic> event in events) {
72-
final String eventName = event['name'];
72+
final String eventName = event['name'] as String;
7373
if (eventName == 'Start Transition') {
7474
assert(startEvent == null);
7575
startEvent = event;
7676
} else if (startEvent != null && eventName == 'Frame') {
77-
final String routeName = startEvent['args']['to'];
77+
final String routeName = startEvent['args']['to'] as String;
7878
durations[routeName] ??= <int>[];
79-
durations[routeName].add(event['dur']);
79+
durations[routeName].add(event['dur'] as int);
8080
startEvent = null;
8181
}
8282
}
@@ -101,13 +101,13 @@ Future<void> saveDurationsHistogram(List<Map<String, dynamic>> events, String ou
101101
String lastEventName = '';
102102
String lastRouteName = '';
103103
while (eventIter.moveNext()) {
104-
final String eventName = eventIter.current['name'];
104+
final String eventName = eventIter.current['name'] as String;
105105

106106
if (!<String>['Start Transition', 'Frame'].contains(eventName))
107107
continue;
108108

109109
final String routeName = eventName == 'Start Transition'
110-
? eventIter.current['args']['to']
110+
? eventIter.current['args']['to'] as String
111111
: '';
112112

113113
if (eventName == lastEventName && routeName == lastRouteName) {
@@ -192,7 +192,7 @@ void main([List<String> args = const <String>[]]) {
192192
}
193193

194194
// See _handleMessages() in transitions_perf.dart.
195-
_allDemos = List<String>.from(const JsonDecoder().convert(await driver.requestData('demoNames')));
195+
_allDemos = List<String>.from(json.decode(await driver.requestData('demoNames')) as List<dynamic>);
196196
if (_allDemos.isEmpty)
197197
throw 'no demo names found';
198198
});
@@ -221,7 +221,7 @@ void main([List<String> args = const <String>[]]) {
221221
await summary.writeSummaryToFile('transitions', pretty: true);
222222
final String histogramPath = path.join(testOutputsDirectory, 'transition_durations.timeline.json');
223223
await saveDurationsHistogram(
224-
List<Map<String, dynamic>>.from(timeline.json['traceEvents']),
224+
List<Map<String, dynamic>>.from(timeline.json['traceEvents'] as List<dynamic>),
225225
histogramPath);
226226

227227
// Execute the remaining tests.

‎examples/layers/rendering/flex_layout.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void main() {
4848
subrow.add(RenderSolidColorBox(const Color(0x7FCCFFFF), desiredSize: const Size(30.0, 40.0)));
4949
row.add(subrow);
5050
table.add(row);
51-
final FlexParentData rowParentData = row.parentData;
51+
final FlexParentData rowParentData = row.parentData as FlexParentData;
5252
rowParentData.flex = 1;
5353
}
5454

@@ -71,7 +71,7 @@ void main() {
7171
row.add(RenderSolidColorBox(const Color(0xFFCCCCFF), desiredSize: const Size(160.0, 60.0)));
7272
row.mainAxisAlignment = justify;
7373
table.add(row);
74-
final FlexParentData rowParentData = row.parentData;
74+
final FlexParentData rowParentData = row.parentData as FlexParentData;
7575
rowParentData.flex = 1;
7676
}
7777

‎examples/layers/rendering/src/sector_layout.dart

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ class SectorConstraints extends Constraints {
3131
final double maxDeltaTheta;
3232

3333
double constrainDeltaRadius(double deltaRadius) {
34-
return deltaRadius.clamp(minDeltaRadius, maxDeltaRadius);
34+
return deltaRadius.clamp(minDeltaRadius, maxDeltaRadius) as double;
3535
}
3636

3737
double constrainDeltaTheta(double deltaTheta) {
38-
return deltaTheta.clamp(minDeltaTheta, maxDeltaTheta);
38+
return deltaTheta.clamp(minDeltaTheta, maxDeltaTheta) as double;
3939
}
4040

4141
@override
@@ -100,14 +100,14 @@ abstract class RenderSector extends RenderObject {
100100
// RenderSectors always use SectorParentData subclasses, as they need to be
101101
// able to read their position information for painting and hit testing.
102102
@override
103-
SectorParentData get parentData => super.parentData;
103+
SectorParentData get parentData => super.parentData as SectorParentData;
104104

105105
SectorDimensions getIntrinsicDimensions(SectorConstraints constraints, double radius) {
106106
return SectorDimensions.withConstraints(constraints);
107107
}
108108

109109
@override
110-
SectorConstraints get constraints => super.constraints;
110+
SectorConstraints get constraints => super.constraints as SectorConstraints;
111111

112112
@override
113113
void debugAssertDoesMeetConstraints() {
@@ -208,7 +208,7 @@ class RenderSectorWithChildren extends RenderDecoratedSector with ContainerRende
208208
while (child != null) {
209209
if (child.hitTest(result, radius: radius, theta: theta))
210210
return;
211-
final SectorChildListParentData childParentData = child.parentData;
211+
final SectorChildListParentData childParentData = child.parentData as SectorChildListParentData;
212212
child = childParentData.previousSibling;
213213
}
214214
}
@@ -218,7 +218,7 @@ class RenderSectorWithChildren extends RenderDecoratedSector with ContainerRende
218218
RenderSector child = lastChild;
219219
while (child != null) {
220220
visitor(child);
221-
final SectorChildListParentData childParentData = child.parentData;
221+
final SectorChildListParentData childParentData = child.parentData as SectorChildListParentData;
222222
child = childParentData.previousSibling;
223223
}
224224
}
@@ -282,7 +282,7 @@ class RenderSectorRing extends RenderSectorWithChildren {
282282
final SectorDimensions childDimensions = child.getIntrinsicDimensions(innerConstraints, childRadius);
283283
innerTheta += childDimensions.deltaTheta;
284284
remainingDeltaTheta -= childDimensions.deltaTheta;
285-
final SectorChildListParentData childParentData = child.parentData;
285+
final SectorChildListParentData childParentData = child.parentData as SectorChildListParentData;
286286
child = childParentData.nextSibling;
287287
if (child != null) {
288288
innerTheta += paddingTheta;
@@ -316,7 +316,7 @@ class RenderSectorRing extends RenderSectorWithChildren {
316316
child.layout(innerConstraints, parentUsesSize: true);
317317
innerTheta += child.deltaTheta;
318318
remainingDeltaTheta -= child.deltaTheta;
319-
final SectorChildListParentData childParentData = child.parentData;
319+
final SectorChildListParentData childParentData = child.parentData as SectorChildListParentData;
320320
child = childParentData.nextSibling;
321321
if (child != null) {
322322
innerTheta += paddingTheta;
@@ -335,7 +335,7 @@ class RenderSectorRing extends RenderSectorWithChildren {
335335
RenderSector child = firstChild;
336336
while (child != null) {
337337
context.paintChild(child, offset);
338-
final SectorChildListParentData childParentData = child.parentData;
338+
final SectorChildListParentData childParentData = child.parentData as SectorChildListParentData;
339339
child = childParentData.nextSibling;
340340
}
341341
}
@@ -396,7 +396,7 @@ class RenderSectorSlice extends RenderSectorWithChildren {
396396
final SectorDimensions childDimensions = child.getIntrinsicDimensions(innerConstraints, childRadius);
397397
childRadius += childDimensions.deltaRadius;
398398
remainingDeltaRadius -= childDimensions.deltaRadius;
399-
final SectorChildListParentData childParentData = child.parentData;
399+
final SectorChildListParentData childParentData = child.parentData as SectorChildListParentData;
400400
child = childParentData.nextSibling;
401401
childRadius += padding;
402402
remainingDeltaRadius -= padding;
@@ -427,7 +427,7 @@ class RenderSectorSlice extends RenderSectorWithChildren {
427427
child.layout(innerConstraints, parentUsesSize: true);
428428
childRadius += child.deltaRadius;
429429
remainingDeltaRadius -= child.deltaRadius;
430-
final SectorChildListParentData childParentData = child.parentData;
430+
final SectorChildListParentData childParentData = child.parentData as SectorChildListParentData;
431431
child = childParentData.nextSibling;
432432
childRadius += padding;
433433
remainingDeltaRadius -= padding;
@@ -445,7 +445,7 @@ class RenderSectorSlice extends RenderSectorWithChildren {
445445
while (child != null) {
446446
assert(child.parentData is SectorChildListParentData);
447447
context.paintChild(child, offset);
448-
final SectorChildListParentData childParentData = child.parentData;
448+
final SectorChildListParentData childParentData = child.parentData as SectorChildListParentData;
449449
child = childParentData.nextSibling;
450450
}
451451
}
@@ -638,7 +638,7 @@ class SectorHitTestEntry extends HitTestEntry {
638638
super(target);
639639

640640
@override
641-
RenderSector get target => super.target;
641+
RenderSector get target => super.target as RenderSector;
642642

643643
/// The radius component of the hit test position in the local coordinates of
644644
/// [target].

‎examples/layers/rendering/touch_input.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class RenderDots extends RenderBox {
6565
@override
6666
void handleEvent(PointerEvent event, BoxHitTestEntry entry) {
6767
if (event is PointerDownEvent) {
68-
final Color color = _kColors[event.pointer.remainder(_kColors.length)];
68+
final Color color = _kColors[event.pointer.remainder(_kColors.length) as int];
6969
_dots[event.pointer] = Dot(color: color)..update(event);
7070
// We call markNeedsPaint to indicate that our painting commands have
7171
// changed and that paint needs to be called before displaying a new frame
@@ -126,7 +126,7 @@ void main() {
126126
//
127127
// We use the StackParentData of the paragraph to position the text in the top
128128
// left corner of the screen.
129-
final StackParentData paragraphParentData = paragraph.parentData;
129+
final StackParentData paragraphParentData = paragraph.parentData as StackParentData;
130130
paragraphParentData
131131
..top = 40.0
132132
..left = 20.0;

‎examples/layers/services/isolate.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class Calculator {
4444
}
4545
);
4646
try {
47-
final List<dynamic> result = decoder.convert(_data);
47+
final List<dynamic> result = decoder.convert(_data) as List<dynamic>;
4848
final int n = result.length;
4949
onResultListener('Decoded $n results');
5050
} catch (e, stack) {

‎examples/layers/widgets/sectors.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import 'package:flutter/rendering.dart';
99

1010
import '../rendering/src/sector_layout.dart';
1111

12-
RenderBox initCircle() {
12+
RenderBoxToRenderSectorAdapter initCircle() {
1313
return RenderBoxToRenderSectorAdapter(
1414
innerRadius: 25.0,
1515
child: RenderSectorRing(padding: 0.0),
@@ -54,7 +54,7 @@ class SectorAppState extends State<SectorApp> {
5454
int index = 0;
5555
while (index < actualSectorSizes.length && index < wantedSectorSizes.length && actualSectorSizes[index] == wantedSectorSizes[index])
5656
index += 1;
57-
final RenderSectorRing ring = sectors.child;
57+
final RenderSectorRing ring = sectors.child as RenderSectorRing;
5858
while (index < actualSectorSizes.length) {
5959
ring.remove(ring.lastChild);
6060
actualSectorSizes.removeLast();
@@ -67,7 +67,7 @@ class SectorAppState extends State<SectorApp> {
6767
}
6868
}
6969

70-
static RenderBox initSector(Color color) {
70+
static RenderBoxToRenderSectorAdapter initSector(Color color) {
7171
final RenderSectorRing ring = RenderSectorRing(padding: 1.0);
7272
ring.add(RenderSolidColor(const Color(0xFF909090), desiredDeltaTheta: kTwoPi * 0.15));
7373
ring.add(RenderSolidColor(const Color(0xFF909090), desiredDeltaTheta: kTwoPi * 0.15));

‎examples/layers/widgets/spinning_mixed.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import '../rendering/src/solid_color_box.dart';
1111
void addFlexChildSolidColor(RenderFlex parent, Color backgroundColor, { int flex = 0 }) {
1212
final RenderSolidColorBox child = RenderSolidColorBox(backgroundColor);
1313
parent.add(child);
14-
final FlexParentData childParentData = child.parentData;
14+
final FlexParentData childParentData = child.parentData as FlexParentData;
1515
childParentData.flex = flex;
1616
}
1717

‎examples/stocks/lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class StocksAppState extends State<StocksApp> {
7171

7272
Route<dynamic> _getRoute(RouteSettings settings) {
7373
if (settings.name == '/stock') {
74-
final String symbol = settings.arguments;
74+
final String symbol = settings.arguments as String;
7575
return MaterialPageRoute<void>(
7676
settings: settings,
7777
builder: (BuildContext context) => StockSymbolPage(symbol: symbol, stocks: stocks),

‎examples/stocks/lib/stock_data.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,14 @@ class StockData extends ChangeNotifier {
4949
final List<String> _symbols = <String>[];
5050
final Map<String, Stock> _stocks = <String, Stock>{};
5151

52-
Iterable<String> get allSymbols => _symbols;
52+
List<String> get allSymbols => _symbols;
5353

5454
Stock operator [](String symbol) => _stocks[symbol];
5555

5656
bool get loading => _httpClient != null;
5757

5858
void add(List<dynamic> data) {
59-
for (List<dynamic> fields in data) {
59+
for (List<dynamic> fields in data.cast<List<dynamic>>()) {
6060
final Stock stock = Stock.fromFields(fields.cast<String>());
6161
_symbols.add(stock.symbol);
6262
_stocks[stock.symbol] = stock;
@@ -85,7 +85,7 @@ class StockData extends ChangeNotifier {
8585
return;
8686
}
8787
const JsonDecoder decoder = JsonDecoder();
88-
add(decoder.convert(json));
88+
add(decoder.convert(json) as List<dynamic>);
8989
if (_nextChunk < _chunkCount) {
9090
_fetchNextChunk();
9191
} else {

‎examples/stocks/lib/stock_home.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ class StockHomeState extends State<StockHome> {
188188
showAboutDialog(context: context);
189189
}
190190

191-
Widget buildAppBar() {
191+
AppBar buildAppBar() {
192192
return AppBar(
193193
elevation: 0.0,
194194
title: Text(StockStrings.of(context).title),
@@ -283,7 +283,7 @@ class StockHomeState extends State<StockHome> {
283283

284284
static const List<String> portfolioSymbols = <String>['AAPL','FIZZ', 'FIVE', 'FLAT', 'ZINC', 'ZNGA'];
285285

286-
Widget buildSearchBar() {
286+
AppBar buildSearchBar() {
287287
return AppBar(
288288
leading: BackButton(
289289
color: Theme.of(context).accentColor,

‎examples/stocks/lib/stock_settings.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class StockSettingsState extends State<StockSettings> {
9797
widget.updater(value);
9898
}
9999

100-
Widget buildAppBar(BuildContext context) {
100+
AppBar buildAppBar(BuildContext context) {
101101
return AppBar(
102102
title: const Text('Settings'),
103103
);

‎examples/stocks/test/icon_color_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void checkIconColor(WidgetTester tester, String label, Color color) {
4141
final Element listTile = findElementOfExactWidgetTypeGoingUp(tester.element(find.text(label)), ListTile);
4242
expect(listTile, isNotNull);
4343
final Element asset = findElementOfExactWidgetTypeGoingDown(listTile, RichText);
44-
final RichText richText = asset.widget;
44+
final RichText richText = asset.widget as RichText;
4545
expect(richText.text.style.color, equals(color));
4646
}
4747

0 commit comments

Comments
 (0)
Please sign in to comment.