Skip to content

Commit c235998

Browse files
a14nfluttergithubbot
authored andcommitted
implicit-casts: false (flutter#47199)
1 parent 2b4b6ee commit c235998

File tree

21 files changed

+47
-95
lines changed

21 files changed

+47
-95
lines changed

analysis_options.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
analyzer:
2222
strong-mode:
23+
implicit-casts: false
2324
implicit-dynamic: false
2425
errors:
2526
# treat missing required parameters as a warning (not a hint)

dev/devicelab/bin/tasks/fast_scroll_large_images__memory.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class FastScrollLargeImagesMemoryTest extends MemoryTest {
2020
);
2121

2222
@override
23-
AndroidDevice get device => super.device;
23+
AndroidDevice get device => super.device as AndroidDevice;
2424

2525
@override
2626
int get iterationCount => 5;

dev/integration_tests/flutter_driver_screenshot_test/test_driver/driver_screenshot_tester.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44

55
import 'dart:async';
66
import 'dart:io' show File;
7+
8+
import 'package:flutter/foundation.dart';
9+
import 'package:flutter_driver/flutter_driver.dart';
710
import 'package:meta/meta.dart';
811
import 'package:path/path.dart' as path;
9-
import 'package:flutter_driver/flutter_driver.dart';
10-
import 'package:collection/collection.dart';
1112

1213
const String _kPathParent = 'test_driver/goldens/';
1314

@@ -43,8 +44,7 @@ class DriverScreenShotTester {
4344
Future<bool> compareScreenshots(List<int> screenshot) async {
4445
final File file = File(_getImageFilePath());
4546
final List<int> matcher = await file.readAsBytes();
46-
final Function listEquals = const ListEquality<int>().equals;
47-
return listEquals(screenshot, matcher);
47+
return listEquals<int>(screenshot, matcher);
4848
}
4949

5050
/// Returns a bytes representation of a screenshot on the current screen.

dev/tools/localization/bin/gen_l10n.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ Future<void> main(List<String> arguments) async {
5353
exit(0);
5454
}
5555

56-
final String arbPathString = results['arb-dir'];
57-
final String outputFileString = results['output-localization-file'];
58-
final String templateArbFileName = results['template-arb-file'];
59-
final String classNameString = results['output-class'];
56+
final String arbPathString = results['arb-dir'] as String;
57+
final String outputFileString = results['output-localization-file'] as String;
58+
final String templateArbFileName = results['template-arb-file'] as String;
59+
final String classNameString = results['output-class'] as String;
6060

6161
const local.LocalFileSystem fs = local.LocalFileSystem();
6262
final LocalizationsGenerator localizationsGenerator = LocalizationsGenerator(fs);

dev/tools/localization/gen_l10n.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -599,8 +599,8 @@ class LocalizationsGenerator {
599599
for (File file in fileSystemEntityList) {
600600
final String filePath = file.path;
601601
if (arbFilenameRE.hasMatch(filePath)) {
602-
final Map<String, dynamic> arbContents = json.decode(file.readAsStringSync());
603-
String localeString = arbContents['@@locale'];
602+
final Map<String, dynamic> arbContents = json.decode(file.readAsStringSync()) as Map<String, dynamic>;
603+
String localeString = arbContents['@@locale'] as String;
604604
if (localeString == null) {
605605
final RegExpMatch arbFileMatch = arbFilenameLocaleRE.firstMatch(filePath);
606606
if (arbFileMatch == null) {
@@ -653,7 +653,7 @@ class LocalizationsGenerator {
653653
void generateClassMethods() {
654654
Map<String, dynamic> bundle;
655655
try {
656-
bundle = json.decode(templateArbFile.readAsStringSync());
656+
bundle = json.decode(templateArbFile.readAsStringSync()) as Map<String, dynamic>;
657657
} on FileSystemException catch (e) {
658658
throw FileSystemException('Unable to read input arb file: $e');
659659
} on FormatException catch (e) {
@@ -669,7 +669,7 @@ class LocalizationsGenerator {
669669
'Invalid key format: $key \n It has to be in camel case, cannot start '
670670
'with a number, and cannot contain non-alphanumeric characters.'
671671
);
672-
if (pluralValueRE.hasMatch(bundle[key]))
672+
if (pluralValueRE.hasMatch(bundle[key] as String))
673673
classMethods.add(genPluralMethod(bundle, key));
674674
else
675675
classMethods.add(genSimpleMethod(bundle, key));

packages/flutter/lib/src/gestures/mouse_tracking.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ class MouseTracker extends ChangeNotifier {
314314
final int device = state.device;
315315
return (_mouseStates.containsKey(device) && _trackedAnnotations.isNotEmpty)
316316
? LinkedHashSet<MouseTrackerAnnotation>.from(annotationFinder(globalPosition))
317-
: <MouseTrackerAnnotation>{};
317+
: <MouseTrackerAnnotation>{} as LinkedHashSet<MouseTrackerAnnotation>;
318318
}
319319

320320
static bool get _duringBuildPhase {

packages/flutter/lib/src/material/reorderable_list.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ class _ReorderableListContentState extends State<_ReorderableListContent> with T
530530
return _dragging == toAccept && toAccept != toWrap.key;
531531
},
532532
onAccept: (Key accepted) { },
533-
onLeave: (Key leaving) { },
533+
onLeave: (Object leaving) { },
534534
);
535535
});
536536
}

packages/flutter/lib/src/painting/edge_insets.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,12 +162,12 @@ abstract class EdgeInsetsGeometry {
162162
/// or equal to `min`, and less than or equal to `max`.
163163
EdgeInsetsGeometry clamp(EdgeInsetsGeometry min, EdgeInsetsGeometry max) {
164164
return _MixedEdgeInsets.fromLRSETB(
165-
_left.clamp(min._left, max._left),
166-
_right.clamp(min._right, max._right),
167-
_start.clamp(min._start, max._start),
168-
_end.clamp(min._end, max._end),
169-
_top.clamp(min._top, max._top),
170-
_bottom.clamp(min._bottom, max._bottom),
165+
_left.clamp(min._left, max._left) as double,
166+
_right.clamp(min._right, max._right) as double,
167+
_start.clamp(min._start, max._start) as double,
168+
_end.clamp(min._end, max._end) as double,
169+
_top.clamp(min._top, max._top) as double,
170+
_bottom.clamp(min._bottom, max._bottom) as double,
171171
);
172172
}
173173

packages/flutter/lib/src/rendering/layer.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,9 +672,9 @@ class PlatformViewLayer extends Layer {
672672
if (hoverAnnotation == null || !rect.contains(localPosition)) {
673673
return false;
674674
}
675-
if (MouseTrackerAnnotation == S) {
675+
if (S == MouseTrackerAnnotation) {
676676
final Object untypedValue = hoverAnnotation;
677-
final S typedValue = untypedValue;
677+
final S typedValue = untypedValue as S;
678678
result.add(AnnotationEntry<S>(
679679
annotation: typedValue,
680680
localPosition: localPosition,

packages/flutter/lib/src/rendering/proxy_sliver.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import 'dart:ui' as ui show Color;
77
import 'package:flutter/foundation.dart';
88
import 'package:vector_math/vector_math_64.dart';
99

10+
import 'layer.dart';
1011
import 'object.dart';
1112
import 'sliver.dart';
1213

@@ -71,7 +72,7 @@ abstract class RenderProxySliver extends RenderSliver with RenderObjectWithChild
7172
@override
7273
void applyPaintTransform(RenderObject child, Matrix4 transform) {
7374
assert(child != null);
74-
final SliverPhysicalParentData childParentData = child.parentData;
75+
final SliverPhysicalParentData childParentData = child.parentData as SliverPhysicalParentData;
7576
childParentData.applyPaintTransform(transform);
7677
}
7778
}
@@ -169,7 +170,7 @@ class RenderSliverOpacity extends RenderProxySliver {
169170
offset,
170171
_alpha,
171172
_paintWithOpacity,
172-
oldLayer: layer,
173+
oldLayer: layer as OpacityLayer,
173174
);
174175
}
175176
}

packages/flutter/lib/src/widgets/binding.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ mixin WidgetsBinding on BindingBase, ServicesBinding, SchedulerBinding, GestureB
332332
registerServiceExtension(
333333
name: 'fastReassemble',
334334
callback: (Map<String, Object> params) async {
335-
final String className = params['class'];
335+
final String className = params['class'] as String;
336336
void markElementsDirty(Element element) {
337337
if (element == null) {
338338
return;

packages/flutter/lib/src/widgets/drag_target.dart

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ typedef DragEndCallback = void Function(DraggableDetails details);
4848
/// Signature for when a [Draggable] leaves a [DragTarget].
4949
///
5050
/// Used by [DragTarget.onLeave].
51-
typedef DragTargetLeave<T> = void Function(T data);
51+
typedef DragTargetLeave = void Function(Object data);
5252

5353
/// Where the [Draggable] should be anchored during a drag.
5454
enum DragAnchor {
@@ -502,7 +502,7 @@ class DragTarget<T> extends StatefulWidget {
502502

503503
/// Called when a given piece of data being dragged over this target leaves
504504
/// the target.
505-
final DragTargetLeave<T> onLeave;
505+
final DragTargetLeave onLeave;
506506

507507
@override
508508
_DragTargetState<T> createState() => _DragTargetState<T>();
@@ -514,13 +514,12 @@ List<T> _mapAvatarsToData<T>(List<_DragAvatar<T>> avatars) {
514514

515515
class _DragTargetState<T> extends State<DragTarget<T>> {
516516
final List<_DragAvatar<T>> _candidateAvatars = <_DragAvatar<T>>[];
517-
final List<_DragAvatar<dynamic>> _rejectedAvatars = <_DragAvatar<dynamic>>[];
517+
final List<_DragAvatar<Object>> _rejectedAvatars = <_DragAvatar<Object>>[];
518518

519-
bool didEnter(_DragAvatar<dynamic> avatar) {
519+
bool didEnter(_DragAvatar<Object> avatar) {
520520
assert(!_candidateAvatars.contains(avatar));
521521
assert(!_rejectedAvatars.contains(avatar));
522-
final dynamic data = avatar.data;
523-
if (data is T && (widget.onWillAccept == null || widget.onWillAccept(data))) {
522+
if (avatar is _DragAvatar<T> && (widget.onWillAccept == null || widget.onWillAccept(avatar.data))) {
524523
setState(() {
525524
_candidateAvatars.add(avatar);
526525
});
@@ -533,7 +532,7 @@ class _DragTargetState<T> extends State<DragTarget<T>> {
533532
}
534533
}
535534

536-
void didLeave(_DragAvatar<dynamic> avatar) {
535+
void didLeave(_DragAvatar<Object> avatar) {
537536
assert(_candidateAvatars.contains(avatar) || _rejectedAvatars.contains(avatar));
538537
if (!mounted)
539538
return;
@@ -545,15 +544,15 @@ class _DragTargetState<T> extends State<DragTarget<T>> {
545544
widget.onLeave(avatar.data);
546545
}
547546

548-
void didDrop(_DragAvatar<dynamic> avatar) {
547+
void didDrop(_DragAvatar<Object> avatar) {
549548
assert(_candidateAvatars.contains(avatar));
550549
if (!mounted)
551550
return;
552551
setState(() {
553552
_candidateAvatars.remove(avatar);
554553
});
555554
if (widget.onAccept != null)
556-
widget.onAccept(avatar.data);
555+
widget.onAccept(avatar.data as T);
557556
}
558557

559558
@override
@@ -562,7 +561,7 @@ class _DragTargetState<T> extends State<DragTarget<T>> {
562561
return MetaData(
563562
metaData: this,
564563
behavior: HitTestBehavior.translucent,
565-
child: widget.builder(context, _mapAvatarsToData<T>(_candidateAvatars), _mapAvatarsToData<dynamic>(_rejectedAvatars)),
564+
child: widget.builder(context, _mapAvatarsToData<T>(_candidateAvatars), _mapAvatarsToData<Object>(_rejectedAvatars)),
566565
);
567566
}
568567
}

packages/flutter/test/widgets/draggable_test.dart

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,21 @@ void main() {
9090
builder: (BuildContext context, List<int> data, List<dynamic> rejects) {
9191
return Container(height: 100.0, child: const Text('Target 1'));
9292
},
93-
onLeave: (int data) => leftBehind['Target 1'] = leftBehind['Target 1'] + data,
93+
onLeave: (Object data) {
94+
if (data is int) {
95+
leftBehind['Target 1'] = leftBehind['Target 1'] + data;
96+
}
97+
},
9498
),
9599
DragTarget<int>(
96100
builder: (BuildContext context, List<int> data, List<dynamic> rejects) {
97101
return Container(height: 100.0, child: const Text('Target 2'));
98102
},
99-
onLeave: (int data) => leftBehind['Target 2'] = leftBehind['Target 2'] + data,
103+
onLeave: (Object data) {
104+
if (data is int) {
105+
leftBehind['Target 2'] = leftBehind['Target 2'] + data;
106+
}
107+
},
100108
),
101109
],
102110
),

packages/flutter_driver/analysis_options.yaml

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

packages/flutter_goldens/analysis_options.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,3 @@
22
# the ones from above, which include the `public_member_api_docs` rule).
33

44
include: ../../analysis_options.yaml
5-
6-
analyzer:
7-
strong-mode:
8-
implicit-casts: false
9-
implicit-dynamic: false

packages/flutter_goldens_client/analysis_options.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,3 @@
22
# the ones from above, which include the `public_member_api_docs` rule).
33

44
include: ../../analysis_options.yaml
5-
6-
analyzer:
7-
strong-mode:
8-
implicit-casts: false
9-
implicit-dynamic: false

packages/flutter_localizations/analysis_options.yaml

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

packages/flutter_test/analysis_options.yaml

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

packages/flutter_tools/analysis_options.yaml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@
33

44
include: ../../analysis_options.yaml
55

6-
analyzer:
7-
strong-mode:
8-
implicit-casts: false
9-
implicit-dynamic: false
10-
116
linter:
127
rules:
138
unawaited_futures: true

packages/flutter_web_plugins/analysis_options.yaml

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

packages/fuchsia_remote_debug_protocol/analysis_options.yaml

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

0 commit comments

Comments
 (0)