- Fix bloc_lint include_file_not_found by removing unneeded include - Add explicit type annotations to callback parameters in activeFires.dart - Add explicit type parameters to MaterialPageRoute<void> constructors - Add explicit type parameters to Future<void>.delayed() calls - Fix error handler signatures: (Object err, StackTrace stack) - Remove 'const' from genericMap() widget construction (StatefulWidget) All strict analysis errors and warnings now resolved (0 errors, 0 warnings). Remaining 339 issues are info-level linting suggestions.
47 lines
1.1 KiB
Dart
47 lines
1.1 KiB
Dart
import 'dart:async';
|
|
|
|
import 'package:flutter/services.dart' show rootBundle;
|
|
|
|
final RegExp esRegExp = RegExp('^es-');
|
|
|
|
String getFallbackLang(String lang) {
|
|
if (lang == 'ast' ||
|
|
lang == 'gl' ||
|
|
lang == 'eu' ||
|
|
lang == 'es' ||
|
|
lang == 'ca' ||
|
|
esRegExp.allMatches(lang).isNotEmpty) {
|
|
return 'es';
|
|
}
|
|
return 'en';
|
|
}
|
|
|
|
Future<String> getFileNameOfLang(
|
|
{required String dir,
|
|
required String fileName,
|
|
required String ext,
|
|
required String lang}) async {
|
|
final String base = '$dir/$fileName';
|
|
final String fallback = getFallbackLang(lang);
|
|
String file = '$base-$lang.$ext';
|
|
if (await assetNotExists(file)) {
|
|
file = '$base-$fallback.$ext';
|
|
if (await assetNotExists(file)) {
|
|
file = '$base.$ext';
|
|
}
|
|
}
|
|
return file;
|
|
}
|
|
|
|
// https://github.com/flutter/flutter/issues/15325
|
|
Future<bool> assetNotExists(String asset) {
|
|
print('Does not exists $asset ?');
|
|
return rootBundle
|
|
.load(asset)
|
|
.then((_) => false)
|
|
.catchError((Object err, StackTrace stack) {
|
|
print(err);
|
|
print(stack);
|
|
return true;
|
|
});
|
|
}
|