Skip to content

Commit d0c44fe

Browse files
committed
feature: small change, code reuse. fixed example locales
1 parent 671985b commit d0c44fe

File tree

3 files changed

+10
-18
lines changed

3 files changed

+10
-18
lines changed

example/lib/main.dart

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import 'r.dart';
99

1010
void main() {
1111
Stringcare().locales = [
12-
Locale('en', ''),
13-
Locale('es', ''),
12+
Locale('en'),
13+
Locale('es'),
1414
Locale('es', 'AR'),
1515
Locale('es', 'ES'),
1616
Locale('es', 'US')

lib/stringcare.dart

+7-15
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ export 'src/extension/stringcare_ext.dart';
1414
export 'src/i18n/remote_languages.dart';
1515
export 'src/widget/sc_asset_image_provider.dart';
1616
export 'src/widget/sc_image_asset.dart';
17-
export 'src/widget/sc_svg.dart';
1817
export 'src/widget/sc_state.dart';
18+
export 'src/widget/sc_svg.dart';
1919

2020
class Stringcare {
2121
static Stringcare? _instance;
@@ -190,20 +190,6 @@ class Stringcare {
190190
return AppLocalizations.of(context)?.load() ?? Future.value(false);
191191
}
192192

193-
Future<void> refreshWithLang(String? lang) async {
194-
withLang = () => lang;
195-
if (await Stringcare().load()) {
196-
GlobalRefresh().refresh();
197-
}
198-
}
199-
200-
Future<void> refreshWithLocale(Locale? locale) async {
201-
withLocale = () => locale;
202-
if (await Stringcare().load()) {
203-
GlobalRefresh().refresh();
204-
}
205-
}
206-
207193
Future<void> refreshWithLangWithContext(
208194
BuildContext? context,
209195
String? lang,
@@ -223,4 +209,10 @@ class Stringcare {
223209
GlobalRefresh().refresh();
224210
}
225211
}
212+
213+
Future<void> refreshWithLang(String? lang) =>
214+
refreshWithLangWithContext(context, lang);
215+
216+
Future<void> refreshWithLocale(Locale? locale) =>
217+
refreshWithLocaleWithContext(context, locale);
226218
}

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: stringcare
22
description: Flutter plugin for obfuscate and reveal strings and any other data.
3-
version: 0.1.3
3+
version: 0.1.4
44
homepage: https://github.com/StringCare/stringcare
55
repository: https://github.com/StringCare/stringcare
66

0 commit comments

Comments
 (0)