Unverified Commit d30c355d authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

[flutter] allow loading either NOTICES or LICENSE (#58131)

To make #57871 easier to land, add support for loading either LICENSES or NOTICES, preferring the later.
parent 39ffce3e
......@@ -101,7 +101,14 @@ mixin ServicesBinding on BindingBase, SchedulerBinding {
// TODO(ianh): Remove this complexity once these bugs are fixed.
final Completer<String> rawLicenses = Completer<String>();
scheduleTask(() async {
rawLicenses.complete(rootBundle.loadString('LICENSE', cache: false));
// TODO(jonahwilliams): temporary catch to allow migrating LICENSE to NOTICES.
// Once both the tool and google3 use notices this can be removed after PR:
// https://github.com/flutter/flutter/pull/57871
try {
rawLicenses.complete(await rootBundle.loadString('NOTICES', cache: false));
} on FlutterError {
rawLicenses.complete(await rootBundle.loadString('LICENSE', cache: false));
}
}, Priority.animation);
await rawLicenses.future;
final Completer<List<LicenseEntry>> parsedLicenses = Completer<List<LicenseEntry>>();
......
......@@ -44,7 +44,10 @@ class TestBinding extends BindingBase with SchedulerBinding, ServicesBinding {
BinaryMessenger createBinaryMessenger() {
return super.createBinaryMessenger()
..setMockMessageHandler('flutter/assets', (ByteData message) async {
if (const StringCodec().decodeMessage(message) == 'LICENSE') {
// Temporarily check for both LICENSE and NOTICES
// Once both the tool and google3 use notices this can be removed after PR:
// https://github.com/flutter/flutter/pull/57871
if (const StringCodec().decodeMessage(message) == 'LICENSE' || const StringCodec().decodeMessage(message) == 'NOTICES') {
return const StringCodec().encodeMessage(licenses);
}
return null;
......
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