123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- import 'dart:async';
- import 'package:flutter/material.dart';
- import 'package:flutter/services.dart';
- import 'package:flutter_demo/constants.dart';
- import 'Screens/Guide/guide_screen.dart';
- void main() {
- runApp(MyApp());
- }
- class MyApp extends StatelessWidget {
- @override
- Widget build(BuildContext context) {
- // Size size = MediaQuery.of(context).size;
- return MaterialApp(
- debugShowCheckedModeBanner: false,
- title: 'Flutter Demo',
- theme: ThemeData(
- primaryColor: kPrimaryColor,
- scaffoldBackgroundColor: Colors.white,
- primaryColorLight: kPrimaryLightColor),
- home: Scaffold(
- body: SplashScreen(),
- ),
- );
- }
- }
- class SplashScreen extends StatefulWidget {
- const SplashScreen({Key? key}) : super(key: key);
- @override
- State<SplashScreen> createState() => _SplashScreenState();
- }
- class _SplashScreenState extends State<SplashScreen> {
- int _countdown = 3;
- Timer? _countdownTimer;
- @override
- void initState() {
- super.initState();
- _startRecordTime();
- }
- /// 定时自动跳转页面
- void _startRecordTime() {
- _countdownTimer = Timer.periodic(Duration(seconds: 1), (timer) {
- setState(() {
- if (_countdown <= 1) {
- Navigator.of(context).pop();
- Navigator.of(context).push(MaterialPageRoute(builder: (context) {
- return GuideScreen();
- }));
- _countdownTimer?.cancel();
- _countdownTimer = null;
- } else {
- _countdown -= 1;
- }
- });
- });
- }
- @override
- void dispose() {
- super.dispose();
- if (_countdownTimer != null && _countdownTimer!.isActive) {
- _countdownTimer!.cancel();
- _countdownTimer = null;
- }
- }
- @override
- Widget build(BuildContext context) {
- SystemChrome.setEnabledSystemUIOverlays([]);
- Size size = MediaQuery.of(context).size;
- return Container(
- height: size.height,
- width: double.infinity,
- color: Color(0xffc3eff2),
- constraints: BoxConstraints.expand(),
- child: Stack(
- alignment: AlignmentDirectional.bottomCenter,
- children: <Widget>[
- Positioned(
- bottom: 60,
- child: Row(
- children: <Widget>[
- Image(
- image: AssetImage('assets/images/logo.png'),
- width: 80,
- height: 80,
- ),
- Padding(
- padding: const EdgeInsets.only(left: 25),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: <Widget>[
- Text(
- "享有康康",
- style: TextStyle(
- color: Color(0xff42c293),
- fontSize: 24,
- fontStyle: FontStyle.italic,
- fontWeight: FontWeight.w700,
- decoration: TextDecoration.none,
- ),
- ),
- Text(
- "为您的家庭保驾护航",
- style: TextStyle(
- fontWeight: FontWeight.w600,
- decoration: TextDecoration.none,
- fontSize: 15,
- color: Color(0xff6e6e6e)),
- )
- ],
- ),
- )
- ],
- ))
- ],
- ),
- );
- }
- }
|