12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- import 'dart:async';
- import 'package:flutter/material.dart';
- import 'package:flutter_green/pages/guide_page.dart';
- import 'package:flutter_green/pages/login/welcome_page.dart';
- import 'package:shared_preferences/shared_preferences.dart';
- class SplashPage extends StatefulWidget {
- @override
- _SplashPageState createState() => _SplashPageState();
- }
- class _SplashPageState extends State<SplashPage> {
- Future checkFirstSeen() async {
- SharedPreferences preference = await SharedPreferences.getInstance();
- bool _seen = (preference.getBool('guide_flag') ?? false);
- if (_seen) {
- Navigator.of(context).pushReplacement(
- MaterialPageRoute(builder: (context) => WelcomePage()));
- } else {
- preference.setBool('guide_flag', true);
- Navigator.of(context).pushReplacement(
- MaterialPageRoute(builder: (context) => GuidePage()));
- }
- }
- @override
- void initState() {
- super.initState();
- Timer(Duration(milliseconds: 2000), () {
- checkFirstSeen();
- });
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- body: Stack(
- fit: StackFit.expand,
- children: <Widget>[
- Container(
- decoration: BoxDecoration(color: Color(0xFF6ecce2)),
- child: Column(
- mainAxisAlignment: MainAxisAlignment.start,
- children: <Widget>[
- Expanded(
- flex: 2,
- child: Container(
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: <Widget>[
- CircleAvatar(
- backgroundColor: Color(0xFF28152a),
- radius: 50.0,
- child: Image.asset("assets/images/leaf.jpg"),
- ),
- Padding(
- padding: EdgeInsets.only(top: 15.0),
- ),
- Text(
- "欢迎使用绿植App",
- style: TextStyle(
- color: Colors.white,
- fontWeight: FontWeight.bold,
- fontSize: 24.0),
- ),
- ],
- ),
- ),
- ),
- ],
- )),
- ],
- ),
- );
- }
- }
|