Unverified Commit 6b756ab5 authored by Alex Li's avatar Alex Li Committed by GitHub

Improve the format in `asset_bundle.dart` (#126229)

Just found these extra intents and the very long line which might be improved.

Related git blame: https://github.com/flutter/flutter/blame/master/packages/flutter/lib/src/services/asset_bundle.dart#L337.
parent 431dfc83
...@@ -323,7 +323,10 @@ class PlatformAssetBundle extends CachingAssetBundle { ...@@ -323,7 +323,10 @@ class PlatformAssetBundle extends CachingAssetBundle {
@override @override
Future<ByteData> load(String key) { Future<ByteData> load(String key) {
final Uint8List encoded = utf8.encoder.convert(Uri(path: Uri.encodeFull(key)).path); final Uint8List encoded = utf8.encoder.convert(Uri(path: Uri.encodeFull(key)).path);
final Future<ByteData>? future = ServicesBinding.instance.defaultBinaryMessenger.send('flutter/assets', encoded.buffer.asByteData())?.then((ByteData? asset) { final Future<ByteData>? future = ServicesBinding.instance.defaultBinaryMessenger.send(
'flutter/assets',
encoded.buffer.asByteData(),
)?.then((ByteData? asset) {
if (asset == null) { if (asset == null) {
throw FlutterError.fromParts(<DiagnosticsNode>[ throw FlutterError.fromParts(<DiagnosticsNode>[
_errorSummaryWithKey(key), _errorSummaryWithKey(key),
...@@ -334,9 +337,9 @@ class PlatformAssetBundle extends CachingAssetBundle { ...@@ -334,9 +337,9 @@ class PlatformAssetBundle extends CachingAssetBundle {
}); });
if (future == null) { if (future == null) {
throw FlutterError.fromParts(<DiagnosticsNode>[ throw FlutterError.fromParts(<DiagnosticsNode>[
_errorSummaryWithKey(key), _errorSummaryWithKey(key),
ErrorDescription('The asset does not exist or has empty data.'), ErrorDescription('The asset does not exist or has empty data.'),
]); ]);
} }
return future; return future;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment