@@ -29,7 +29,7 @@ class _DefaultSection extends SectionKeyDelegate {
29
29
class _Test extends SectionKeyDelegate {
30
30
const _Test (): super ('test' );
31
31
32
- String get testDollarSign => get ('testDollarSign' , "\$ testing" );
32
+ String get testDollarSign => get ('testDollarSign' , "\$ testing change back " );
33
33
String get testSingleQuotationMark => get ('testSingleQuotationMark' , "\' testing\' " );
34
34
String get testDoubleQuotationMark => get ('testDoubleQuotationMark' , "\" testing\" " );
35
35
String get testMultipleLines => get ('testMultipleLines' , "testing\n multiple\n lines" );
@@ -43,7 +43,7 @@ final _languages = [
43
43
];
44
44
45
45
const _bundledTranslations = {
46
- 'en-EN' : r'''{"data":{"default":{"title":"NStack SDK Demo","test":"test"},"test":{"testDollarSign":"$testing","testSingleQuotationMark":"'testing'","testDoubleQuotationMark":"\"testing\"","testMultipleLines":"testing\nmultiple\nlines"}},"meta":{"language":{"id":56,"name":"English","locale":"en-EN","direction":"LRM","is_default":false,"is_best_fit":false},"platform":{"id":515,"slug":"mobile"}}}''' ,
46
+ 'en-EN' : r'''{"data":{"default":{"title":"NStack SDK Demo","test":"test"},"test":{"testDollarSign":"$testing change back ","testSingleQuotationMark":"'testing'","testDoubleQuotationMark":"\"testing\"","testMultipleLines":"testing\nmultiple\nlines"}},"meta":{"language":{"id":56,"name":"English","locale":"en-EN","direction":"LRM","is_default":false,"is_best_fit":false},"platform":{"id":515,"slug":"mobile"}}}''' ,
47
47
'de-AT' : r'''{"data":{"default":{"title":"NStack SDK Demo","test":"test"},"test":{"testDollarSign":"__testDollarSign","testSingleQuotationMark":"__testSingleQuotationMark","testDoubleQuotationMark":"__testDoubleQuotationMark","testMultipleLines":"__testMultipleLines"}},"meta":{"language":{"id":7,"name":"German (Austria)","locale":"de-AT","direction":"LRM","is_default":false,"is_best_fit":false},"platform":{"id":515,"slug":"mobile"}}}''' ,
48
48
};
49
49
@@ -87,33 +87,44 @@ class NStackState extends State<NStackWidget> {
87
87
final NStack <Localization > nstack = _nstack;
88
88
89
89
changeLanguage (Locale locale) async {
90
- await _nstack.changeLocalization (locale);
91
- setState (() {});
90
+ await _nstack.changeLocalization (locale).whenComplete (() => setState (() {}));
92
91
}
93
92
93
+ Future <void > appOpen (Locale locale) async {
94
+ await _nstack.appOpen (locale).whenComplete (() => setState (() {}));
95
+ }
96
+
94
97
@override
95
98
Widget build (BuildContext context) {
96
99
return NStackScope (child: widget.child, state: this , nstack: this .nstack, checksum: nstack.checksum,);
97
100
}
98
101
}
99
102
100
103
class NStackAppOpen extends StatefulWidget {
101
- const NStackAppOpen ({Key ? key, required this .child}) : super (key: key);
104
+ const NStackAppOpen ({
105
+ Key ? key,
106
+ required this .child,
107
+ this .onComplete,
108
+ }) : super (key: key);
102
109
103
110
final Widget child;
111
+ final VoidCallback ? onComplete;
104
112
105
113
@override
106
114
_NStackAppOpenState createState () => _NStackAppOpenState ();
107
115
}
108
116
109
117
class _NStackAppOpenState extends State <NStackAppOpen > {
110
- bool _initializedNStack = false ;
118
+ bool _initializedNStack = false ;
119
+
111
120
@override
112
121
Widget build (BuildContext context) {
113
- if (! _initializedNStack) {
114
- NStackScope .of (context).nstack.appOpen (Localizations .localeOf (context));
115
- _initializedNStack = true ;
116
- }
122
+ if (! _initializedNStack) {
123
+ NStackScope .of (context)
124
+ .appOpen (Localizations .localeOf (context))
125
+ .whenComplete (() => widget.onComplete? .call ());
126
+ _initializedNStack = true ;
127
+ }
117
128
return widget.child;
118
129
}
119
130
}
0 commit comments