loadString method
- String asset
Retrieves a String from the asset bundle.
Caches the response with the current Pubspec.ref version.
Implementation
Future<String> loadString(String asset) async {
String? contents;
// Browser may cache the GET request too persistent, even when the file is
// indeed changed.
if (PlatformUtils.isWeb) {
try {
final response = await (await (PlatformUtils.dio)).get(
'${Config.origin}/assets/$asset?${Pubspec.ref}',
options: Options(responseType: ResponseType.plain),
);
if (response.data is String) {
contents = response.data as String;
}
} catch (_) {
// No-op.
}
}
return contents ?? await rootBundle.loadString(asset);
}