Ad
Flutter & Introduction Slider : How Do We Know That It Is The First Time Our User Open The Open?
Flutter & Introduction Slider :
I want to include introduction slider using this Intro_Slider
Plugin.
How do we determine when is the first time our user uses the app?
Ad
Answer
You can define a boolean field as isFirstTime
and set it to true
default value. In initState()
of Intro_Slider
you can set it to false, that means user visited this page. And you can save it into LocalStorage
. After that you can check this value and if isFirstTime
is false then you can pass this page.
Add package in pubspec.yaml
:
dependencies:
shared_preferences: ^0.5.8
Import it:
import 'package:shared_preferences/shared_preferences.dart';
Then:
@override
void initState() {
super.initState();
checkIsFirstTime();
}
void checkIsFirstTime() async {
final SharedPreferences prefs = await SharedPreferences.getInstance();
final bool isFirstTime = prefs.getBool('isFirstTime');
// check is null or true
if (isFirstTime == null || isFirstTime) {
prefs.setBool('isFirstTime', false);
}
else {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => HomePage()),
}
}
You can read more.
Ad
source: stackoverflow.com
Related Questions
- → How do you create a 12 or 24 mnemonics code for multiple cryptocurrencies (ETH, BTC and so on..)
- → Flutter: input text field don't work properly in a simple example..... where am I wrong?
- → Can I customize the code formatting of Dart code in Atom?
- → Is it possible to develop iOS apps with Flutter on a Linux virtual machine?
- → Display SnackBar in Flutter
- → JSON ObjectMapper in Flutter
- → Material flutter app source code
- → TabBarSelection No such method error
- → How do I set the animation color of a LinearProgressIndicator?
- → Add different routes/screens to Flutter app
- → Is there a way to get the size of an existing widget?
- → How to share a file using flutter
- → Is there an easy way to find particular text built from RichText in a Flutter test?
Ad