@@ -72,12 +72,27 @@ class SurveyKit extends StatefulWidget {
7272class _SurveyKitState extends State <SurveyKit > {
7373 late TaskNavigator _taskNavigator;
7474 late final GlobalKey <NavigatorState > _navigatorKey;
75+ late final SurveyStateProvider _surveyStateProvider;
7576
7677 @override
7778 void initState () {
7879 super .initState ();
7980 _taskNavigator = _createTaskNavigator ();
8081 _navigatorKey = GlobalKey <NavigatorState >();
82+ _surveyStateProvider = SurveyStateProvider (
83+ taskNavigator: _taskNavigator,
84+ onResult: widget.onResult,
85+ stepShell: widget.stepShell,
86+ navigatorKey: _navigatorKey,
87+ child: SurveyPage (
88+ backgroundColor: widget.backgroundColor,
89+ length: widget.task.steps.length,
90+ onResult: widget.onResult,
91+ appBar: widget.appBar,
92+ navigatorKey: _navigatorKey,
93+ decoration: widget.decoration,
94+ ),
95+ );
8196 }
8297
8398 TaskNavigator _createTaskNavigator () {
@@ -106,20 +121,7 @@ class _SurveyKitState extends State<SurveyKit> {
106121 surveyController: widget.surveyController ?? SurveyController (),
107122 localizations: widget.localizations,
108123 padding: const EdgeInsets .all (14 ),
109- child: SurveyStateProvider (
110- taskNavigator: _taskNavigator,
111- onResult: widget.onResult,
112- stepShell: widget.stepShell,
113- navigatorKey: _navigatorKey,
114- child: SurveyPage (
115- backgroundColor: widget.backgroundColor,
116- length: widget.task.steps.length,
117- onResult: widget.onResult,
118- appBar: widget.appBar,
119- navigatorKey: _navigatorKey,
120- decoration: widget.decoration,
121- ),
122- ),
124+ child: _surveyStateProvider,
123125 );
124126 }
125127}
0 commit comments