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.
This commit is contained in:
Alex Li 2023-05-09 03:13:24 +08:00 committed by GitHub
parent 431dfc8326
commit 6b756ab5ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -323,7 +323,10 @@ class PlatformAssetBundle extends CachingAssetBundle {
@override
Future<ByteData> load(String key) {
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) {
throw FlutterError.fromParts(<DiagnosticsNode>[
_errorSummaryWithKey(key),
@ -334,9 +337,9 @@ class PlatformAssetBundle extends CachingAssetBundle {
});
if (future == null) {
throw FlutterError.fromParts(<DiagnosticsNode>[
_errorSummaryWithKey(key),
ErrorDescription('The asset does not exist or has empty data.'),
]);
_errorSummaryWithKey(key),
ErrorDescription('The asset does not exist or has empty data.'),
]);
}
return future;
}