[web] clean up dynamic calls, remove always_specify_types (flutter/engine#53228)
Remove the `avoid_dynamic_calls` exception in `web_ui`, and clean up all dynamic calls.
This commit is contained in:
@@ -8,8 +8,6 @@ include: ../../analysis_options.yaml
|
||||
|
||||
linter:
|
||||
rules:
|
||||
always_specify_types: true # avoid_dynamic_calls needs to be cleaned up before we can start relying on type inference
|
||||
avoid_dynamic_calls: false
|
||||
avoid_print: false
|
||||
avoid_setters_without_getters: false
|
||||
library_private_types_in_public_api: false
|
||||
|
||||
@@ -73,11 +73,12 @@ class RollFallbackFontsCommand extends Command<bool>
|
||||
(googleFontsResult['items'] as List<dynamic>)
|
||||
.cast<Map<String, dynamic>>();
|
||||
final Map<String, Uri> urlForFamily = <String, Uri>{};
|
||||
for (final Map<String, dynamic> fontData in fontDatas) {
|
||||
for (final Map<String, Object?> fontData in fontDatas) {
|
||||
if (fallbackFonts.contains(fontData['family'])) {
|
||||
final Uri uri = Uri.parse(fontData['files']['regular'] as String)
|
||||
final files = fontData['files']! as Map<String, Object?>;
|
||||
final Uri uri = Uri.parse(files['regular']! as String)
|
||||
.replace(scheme: 'https');
|
||||
urlForFamily[fontData['family'] as String] = uri;
|
||||
urlForFamily[fontData['family']! as String] = uri;
|
||||
}
|
||||
}
|
||||
final Map<String, String> charsetForFamily = <String, String>{};
|
||||
|
||||
@@ -156,12 +156,12 @@ class RunSuiteStep implements PipelineStep {
|
||||
throw ToolExit('Could not find built bundle ${suite.testBundle.name.ansiMagenta} for suite ${suite.name.ansiCyan}.');
|
||||
}
|
||||
final String jsonString = resultsJsonFile.readAsStringSync();
|
||||
final dynamic jsonContents = const JsonDecoder().convert(jsonString);
|
||||
final dynamic results = jsonContents['results'];
|
||||
final jsonContents = const JsonDecoder().convert(jsonString) as Map<String, Object?>;
|
||||
final results = jsonContents['results']! as Map<String, Object?>;
|
||||
final List<String> testPaths = <String>[];
|
||||
results.forEach((dynamic k, dynamic v) {
|
||||
final String result = v as String;
|
||||
final String testPath = k as String;
|
||||
results.forEach((Object? k, Object? v) {
|
||||
final String result = v! as String;
|
||||
final String testPath = k! as String;
|
||||
if (testFiles != null) {
|
||||
if (!testFiles!.contains(FilePath.fromTestSet(suite.testBundle.testSet, testPath))) {
|
||||
return;
|
||||
|
||||
@@ -12,20 +12,20 @@ import 'view_embedder/flutter_view_manager.dart';
|
||||
/// The type of a function that initializes an engine (in Dart).
|
||||
typedef InitEngineFn = Future<void> Function([JsFlutterConfiguration? params]);
|
||||
|
||||
/// The signature of the `runApp` function passed to [AppBootstrap].
|
||||
typedef AppBootstrapRunAppFn = Future<void> Function();
|
||||
|
||||
/// A class that controls the coarse lifecycle of a Flutter app.
|
||||
class AppBootstrap {
|
||||
/// Construct an AppBootstrap.
|
||||
AppBootstrap({required InitEngineFn initializeEngine, required Function runApp}) :
|
||||
AppBootstrap({required InitEngineFn initializeEngine, required AppBootstrapRunAppFn runApp}) :
|
||||
_initializeEngine = initializeEngine, _runApp = runApp;
|
||||
|
||||
// A function to initialize the engine.
|
||||
final InitEngineFn _initializeEngine;
|
||||
|
||||
// A function to run the app.
|
||||
//
|
||||
// TODO(dit): Be more strict with the typedef of this function, so we can add
|
||||
// typed params to the function. (See InitEngineFn).
|
||||
final Function _runApp;
|
||||
final AppBootstrapRunAppFn _runApp;
|
||||
|
||||
/// Immediately bootstraps the app.
|
||||
///
|
||||
|
||||
@@ -23,7 +23,7 @@ class ClipboardMessageHandler {
|
||||
const MethodCodec codec = JSONMethodCodec();
|
||||
bool errorEnvelopeEncoded = false;
|
||||
_copyToClipboardStrategy
|
||||
.setData(methodCall.arguments['text'] as String?)
|
||||
.setData((methodCall.arguments as Map<String, Object?>)['text'] as String?)
|
||||
.then((bool success) {
|
||||
if (success) {
|
||||
callback!(codec.encodeSuccessEnvelope(true));
|
||||
|
||||
@@ -535,7 +535,7 @@ class EnginePlatformDispatcher extends ui.PlatformDispatcher {
|
||||
if (renderer is CanvasKitRenderer) {
|
||||
assert(
|
||||
decoded.arguments is int,
|
||||
'Argument to Skia.setResourceCacheMaxBytes must be an int, but was ${decoded.arguments.runtimeType}',
|
||||
'Argument to Skia.setResourceCacheMaxBytes must be an int, but was ${(decoded.arguments as Object?).runtimeType}',
|
||||
);
|
||||
final int cacheSizeInBytes = decoded.arguments as int;
|
||||
CanvasKitRenderer.instance.resourceCacheMaxBytes =
|
||||
|
||||
@@ -412,16 +412,18 @@ class StandardMessageCodec implements MessageCodec<dynamic> {
|
||||
result = buffer.getFloat64List(length);
|
||||
case _valueList:
|
||||
final int length = readSize(buffer);
|
||||
result = <dynamic>[];
|
||||
final theResult = <Object?>[];
|
||||
for (int i = 0; i < length; i++) {
|
||||
result.add(readValue(buffer));
|
||||
theResult.add(readValue(buffer));
|
||||
}
|
||||
result = theResult;
|
||||
case _valueMap:
|
||||
final int length = readSize(buffer);
|
||||
result = <dynamic, dynamic>{};
|
||||
final theResult = <Object?, Object?>{};
|
||||
for (int i = 0; i < length; i++) {
|
||||
result[readValue(buffer)] = readValue(buffer);
|
||||
theResult[readValue(buffer)] = readValue(buffer);
|
||||
}
|
||||
result = theResult;
|
||||
default:
|
||||
throw const FormatException('Message corrupted');
|
||||
}
|
||||
|
||||
@@ -2184,9 +2184,10 @@ class TextEditingChannel {
|
||||
final TextInputCommand command;
|
||||
switch (call.method) {
|
||||
case 'TextInput.setClient':
|
||||
final args = call.arguments! as List<Object?>;
|
||||
command = TextInputSetClient(
|
||||
clientId: call.arguments[0] as int,
|
||||
configuration: InputConfiguration.fromFrameworkMessage(call.arguments[1] as Map<String, dynamic>),
|
||||
clientId: args[0]! as int,
|
||||
configuration: InputConfiguration.fromFrameworkMessage(args[1]! as Map<String, Object?>),
|
||||
);
|
||||
|
||||
case 'TextInput.updateConfig':
|
||||
|
||||
@@ -54,7 +54,7 @@ Future<JsFlutterConfiguration?> bootstrapAndExtractConfig() {
|
||||
final Completer<JsFlutterConfiguration?> configCompleter = Completer<JsFlutterConfiguration?>();
|
||||
final AppBootstrap bootstrap = AppBootstrap(
|
||||
initializeEngine: ([JsFlutterConfiguration? config]) async => configCompleter.complete(config),
|
||||
runApp: () {}
|
||||
runApp: () async {}
|
||||
);
|
||||
final FlutterLoader? loader = flutter?.loader;
|
||||
if (loader == null || loader.isAutoStart) {
|
||||
|
||||
@@ -34,7 +34,7 @@ void testMain() {
|
||||
await Future<void>.delayed(const Duration(milliseconds: 1));
|
||||
}
|
||||
|
||||
void mockRunApp () {
|
||||
Future<void> mockRunApp () async {
|
||||
runCalled = callOrder++;
|
||||
}
|
||||
|
||||
|
||||
@@ -279,13 +279,15 @@ void testMain() {
|
||||
await callback.future;
|
||||
expect(myWindow.browserHistory, isA<MultiEntriesBrowserHistory>());
|
||||
expect(myWindow.browserHistory.urlStrategy!.getPath(), '/baz');
|
||||
final dynamic wrappedState = myWindow.browserHistory.urlStrategy!.getState();
|
||||
final dynamic actualState = wrappedState['state'];
|
||||
final wrappedState = myWindow.browserHistory.urlStrategy!.getState()! as Map<Object?, Object?>;
|
||||
final actualState = wrappedState['state']! as Map<Object?, Object?>;
|
||||
expect(actualState['state1'], true);
|
||||
expect(actualState['state2'], 1);
|
||||
expect(actualState['state3'], 'string');
|
||||
expect(actualState['state4']['substate1'], 1.0);
|
||||
expect(actualState['state4']['substate2'], 'string2');
|
||||
|
||||
final state4 = actualState['state4']! as Map<Object?, Object?>;
|
||||
expect(state4['substate1'], 1.0);
|
||||
expect(state4['substate2'], 'string2');
|
||||
});
|
||||
|
||||
test('routeInformationUpdated can handle uri',
|
||||
|
||||
Reference in New Issue
Block a user