Skip to content

Commit

Permalink
perf: improve network file translation loader
Browse files Browse the repository at this point in the history
  • Loading branch information
ilteoood committed Jul 10, 2024
1 parent 8adf53b commit 99d613b
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions lib/loaders/network_file_translation_loader.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'dart:async';
import 'dart:convert';

import 'package:http/http.dart' as http;

Expand All @@ -11,25 +10,26 @@ class NetworkFileTranslationLoader extends FileTranslationLoader {

NetworkFileTranslationLoader(
{required this.baseUri,
forcedLocale,
fallbackFile = "en",
separator = "_",
useCountryCode = false,
useScriptCode = false,
decodeStrategies})
forcedLocale,
fallbackFile = "en",
separator = "_",
useCountryCode = false,
useScriptCode = false,
decodeStrategies})
: super(
fallbackFile: fallbackFile,
separator: separator,
useCountryCode: useCountryCode,
forcedLocale: forcedLocale,
decodeStrategies: decodeStrategies);
fallbackFile: fallbackFile,
separator: separator,
useCountryCode: useCountryCode,
forcedLocale: forcedLocale,
decodeStrategies: decodeStrategies);

/// Load the file using an http client
@override
Future<String> loadString(final String fileName, final String extension) async {
Future<String> loadString(
final String fileName, final String extension) async {
final resolvedUri = resolveUri(fileName, extension);
final result = await http.get(resolvedUri);
return utf8.decode(result.bodyBytes);
return result.body;
}

Uri resolveUri(final String fileName, final String extension) {
Expand Down

0 comments on commit 99d613b

Please sign in to comment.