我是 flutter 的初学者,我已经创建了我的应用程序,但我想检查用户安装后是否第一次打开应用程序,我看过这篇文章但不知道怎么做?
这是初始屏幕代码,该代码在 3 秒后将用户直接移动到主屏幕,但我想检查用户是否第一次打开应用程序并将用户移动到欢迎屏幕,或者用户是否不是第一次并移动用户到主屏幕。
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:book_pen/main.dart';
import 'package:book_pen/Welcome.dart';
void main() {
runApp(new MaterialApp(
home: new SplashScreen(),
routes: <String, WidgetBuilder>{
'/HomePage': (BuildContext context) => new HomePage(),
'/WelcomePage': (BuildContext context) => new WelcomePage()
},
));
}
class SplashScreen extends StatefulWidget {
@override
_SplashScreenState createState() => new _SplashScreenState();
}
class _SplashScreenState extends State<SplashScreen> {
startTime() async {
var _duration = new Duration(seconds: 3);
return new Timer(_duration, navigationPageHome);
}
void navigationPageHome() {
Navigator.of(context).pushReplacementNamed('/HomePage');
}
void navigationPageWel() …Run Code Online (Sandbox Code Playgroud)