diff --git a/packages/flutter/lib/src/services/asset_bundle.dart b/packages/flutter/lib/src/services/asset_bundle.dart index 6c66a6c673..e9550a8b8a 100644 --- a/packages/flutter/lib/src/services/asset_bundle.dart +++ b/packages/flutter/lib/src/services/asset_bundle.dart @@ -66,8 +66,11 @@ abstract class AssetBundle { /// implementation.) Future loadString(String key, { bool cache = true }) async { final ByteData data = await load(key); + // Note: data has a non-nullable type, but might be null when running with + // weak checking, so we need to null check it anyway (and ignore the warning + // that the null-handling logic is dead code). if (data == null) - throw FlutterError('Unable to load asset: $key'); + throw FlutterError('Unable to load asset: $key'); // ignore: dead_code if (data.lengthInBytes < 10 * 1024) { // 10KB takes about 3ms to parse on a Pixel 2 XL. // See: https://github.com/dart-lang/sdk/issues/31954 diff --git a/packages/flutter/lib/src/services/platform_channel.dart b/packages/flutter/lib/src/services/platform_channel.dart index 2e12e495aa..7d6b0d9eec 100644 --- a/packages/flutter/lib/src/services/platform_channel.dart +++ b/packages/flutter/lib/src/services/platform_channel.dart @@ -88,7 +88,7 @@ class BasicMessageChannel { /// /// This is intended for testing. Messages intercepted in this manner are not /// sent to platform plugins. - void setMockMessageHandler(Future Function(T message) handler) { + void setMockMessageHandler(Future Function(T message)? handler) { if (handler == null) { binaryMessenger.setMockMessageHandler(name, null); } else {