Skip to content

Commit 340d9e0

Browse files
authored
Fix various strong mode issues. (flutter#14284)
1 parent 1227961 commit 340d9e0

File tree

7 files changed

+20
-6
lines changed

7 files changed

+20
-6
lines changed

dev/devicelab/bin/tasks/technical_debt__cost.dart

+4
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ const double todoCost = 1009.0; // about two average SWE days, in dollars
1515
const double ignoreCost = 2003.0; // four average SWE days, in dollars
1616
const double pythonCost = 3001.0; // six average SWE days, in dollars
1717
const double skipCost = 2473.0; // 20 hours: 5 to fix the issue we're ignoring, 15 to fix the bugs we missed because the test was off
18+
const double asDynamicCost = 2003.0; // same as ignoring analyzer warning
1819

1920
final RegExp todoPattern = new RegExp(r'(?://|#) *TODO');
2021
final RegExp ignorePattern = new RegExp(r'// *ignore:');
22+
final RegExp asDynamicPattern = new RegExp(r'as dynamic');
2123

2224
Future<double> findCostsForFile(File file) async {
2325
if (path.extension(file.path) == '.py')
@@ -33,6 +35,8 @@ Future<double> findCostsForFile(File file) async {
3335
total += todoCost;
3436
if (line.contains(ignorePattern))
3537
total += ignoreCost;
38+
if (line.contains(asDynamicPattern))
39+
total += asDynamicCost;
3640
if (isTest && line.contains('skip:'))
3741
total += skipCost;
3842
}

examples/flutter_gallery/lib/demo/material/expansion_panels_demo.dart

+3-1
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ class DemoItem<T> {
168168
);
169169
};
170170
}
171+
172+
Widget build() => builder(this);
171173
}
172174

173175
class ExpasionPanelsDemo extends StatefulWidget {
@@ -351,7 +353,7 @@ class _ExpansionPanelsDemoState extends State<ExpasionPanelsDemo> {
351353
return new ExpansionPanel(
352354
isExpanded: item.isExpanded,
353355
headerBuilder: item.headerBuilder,
354-
body: item.builder(item)
356+
body: item.build()
355357
);
356358
}).toList()
357359
),

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,8 @@ class _NestedScrollController extends ScrollController {
867867
}
868868

869869
Iterable<_NestedScrollPosition> get nestedPositions sync* {
870-
yield* positions;
870+
// TODO(vegorov) use instance method version of castFrom when it is available.
871+
yield* Iterable.castFrom<ScrollPosition, _NestedScrollPosition>(positions);
871872
}
872873
}
873874

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ class _GlowingOverscrollIndicatorState extends State<GlowingOverscrollIndicator>
198198
}
199199
}
200200
} else if (notification is ScrollEndNotification || notification is ScrollUpdateNotification) {
201-
if (notification.dragDetails != null) { // ignore: undefined_getter
201+
if ((notification as dynamic).dragDetails != null) {
202202
_leadingController.scrollEnd();
203203
_trailingController.scrollEnd();
204204
}

packages/flutter_test/lib/src/binding.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase
463463
));
464464
assert(_parentZone != null);
465465
assert(_pendingExceptionDetails != null, 'A test overrode FlutterError.onError but either failed to return it to its original state, or had unexpected additional errors that it could not handle. Typically, this is caused by using expect() before restoring FlutterError.onError.');
466-
_parentZone.run<Null>(_testCompletionHandler);
466+
_parentZone.run<void>(_testCompletionHandler);
467467
}
468468
);
469469
_parentZone = Zone.current;

packages/flutter_test/lib/src/controller.dart

+5-1
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,12 @@ class WidgetController {
132132
Iterable<State> get allStates {
133133
TestAsyncUtils.guardSync();
134134
return allElements
135+
// TODO(vegorov) replace with Iterable.whereType, when it is available. https://github.com/dart-lang/sdk/issues/27827
135136
.where((Element element) => element is StatefulElement)
136-
.map((StatefulElement element) => element.state); // ignore: STRONG_MODE_INVALID_CAST_FUNCTION_EXPR, https://github.com/dart-lang/sdk/issues/27827
137+
.map((Element element) {
138+
final StatefulElement statefulElement = element;
139+
return statefulElement.state;
140+
});
137141
}
138142

139143
/// The matching state in the widget tree.

packages/flutter_tools/lib/src/test/flutter_platform.dart

+4-1
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,10 @@ void main() {
479479
return test.main;
480480
});
481481
WebSocket.connect(server).then((WebSocket socket) {
482-
socket.map(JSON.decode).pipe(channel.sink);
482+
socket.map((dynamic x) {
483+
assert(x is String);
484+
return JSON.decode(x);
485+
}).pipe(channel.sink);
483486
socket.addStream(channel.stream.map(JSON.encode));
484487
});
485488
}

0 commit comments

Comments
 (0)