splash page flutter

main.dart:

import 'package:flutter/material.dart';
import 'dart:async';
import 'dart:ui';
import 'app.dart';

void main()=>runApp(MyApp());

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
routes: <String, WidgetBuilder> {
'/app': (_) => AppPage(),
},
home: HomePage(),
);
}
}

class HomePage extends StatefulWidget {
@override
_HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: InkWell(
child: Image.asset('images/7.jpg',fit: BoxFit.fill,),
onTap: (){
Navigator.pushNamed(context, "/app");
},
),
);
}

@override
void initState() {
super.initState();
countDown();
}

// 倒计时
void countDown() {
var _duration = Duration(seconds: 3);
new Future.delayed(_duration, go2HomePage);
}

void go2HomePage() {
Navigator.of(context).pushReplacementNamed('/app');
}
}


app.dart
import 'package:flutter/material.dart';

class AppPage extends StatefulWidget {
@override
_AppPageState createState() => _AppPageState();
}

class _AppPageState extends State<AppPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.orange.shade100,
body: Column(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
ListTile(
title: Text('hello world'),
subtitle: Text('Love you so much the beautiful world'),
),
ListTile(
title: Text('hello world'),
subtitle: Text('Love you so much the beautiful world'),
),
ListTile(
title: Text('hello world'),
subtitle: Text('Love you so much the beautiful world'),
),
],
),
);
}
}
posted @ 2019-07-04 21:43  braveheart007  阅读(310)  评论(0编辑  收藏  举报