body: Container(
child: new Stepper(
--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/6d5c2797-17c5-452f-879c-7d412d2df928%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/7b955373-1e6c-44cb-afd1-0f4557ff7ce1%40Spark.
I don't think the solution is exactly correct although certainly close -- IIRC reading shared_prefs is an async operation -- which you can't do exactly in initState() ..So in initState you can call another function that is async() and then read the shared_prefs and then do something likevoid getPrefs() async {bool _someBool = await shared_prefs.get('foo'); // or whatever the syntax isif(mounted) {setState(() => {});}Sort of thing .. the syntax isn't exactly right its from the top of my head .. then have the condition like you did ..Cheers
On Jun 6, 2019, at 12:51 PM, Andy Greenshaw <andy...@gmail.com> wrote:
Read the shared_prefs in initState() and set your bool accordingly, then show empty Container if you don’t want the Stepper.child: myBool ? Stepper(…) : Container();
Cheers,
Andy
On 6 Jun 2019, 17:46 +0100, Gavin Henry <gavin...@gmail.com>, wrote:
Hi all,I'm using a Stepper for a setup wizard and shared_prefs to save that setup is complete.I only want to show this Stepper based on that bool. Where the best place to do this in below in my Scaffold?Thanks!body: Container(
child: new Stepper(--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutt...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/6d5c2797-17c5-452f-879c-7d412d2df928%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutt...@googlegroups.com.
Read the shared_prefs in initState() and set your bool accordingly, then show empty Container if you don’t want the Stepper.child: myBool ? Stepper(…) : Container();
_firebaseMessaging.getToken().then((String token) {
assert(token != null);
_loadSetupComplete();
setState(() {
fcmToken = token;
});
print("Push Messaging token: $fcmToken");
// User has cleared app data, re-run Wizard:
// https://firebase.google.com/docs/reference/android/com/google/firebase/iid/FirebaseInstanceId
if (fcmToken != savedFcmToken) {
_setFcmToken();
_setupNeeded();
}
});
_loadSetupComplete() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
setState(() {
setupComplete = prefs.getBool('setupComplete');
print("Loading setupComplete as: $setupComplete");
});
}
_setSetupComplete() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
await prefs.setBool('setupComplete', true);
setState(() {
setupComplete = true;
});
print("Setting setupComplete to true.");
}
Have you considered using a FutureBuilder?
String qrCode = await BarcodeScanner.scan();inside a static step. Doh.
List<Step> setupSteps = [
Step(
title: Text("Step 1"),
subtitle: Text("Find your QR Code"),
content: Text(
"On your desktop, please go to $SUREVOIP_PORTAL and navigate to:" +
"\n\nSettings -> Notifications"),
isActive: true),
Step(
title: Text("Step 2"),
subtitle: Text("Scan your QR Code"),
content: Text("Get ready!"),
isActive: true),
Step(
title: Text("Step 3"),
subtitle: Text("Test your notifications"),
content: Text("Make a test call to one of your numbers."),
state: StepState.complete,
isActive: true),
];