/**
* 廣告頁,3秒自動(dòng)跳轉(zhuǎn)到首頁
*/
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:zybdapp/youshang/main_screen.dart';
void main() {
runApp(new MaterialApp(
title: 'ad',
home: new SplashScreen(),
routes: <String, WidgetBuilder>{
'/main': (BuildContext context) => new MainScreen()
},
));
}
class SplashScreen extends StatefulWidget {
@override
_SplashScreenState createState() => new _SplashScreenState();
}
class _SplashScreenState extends State<SplashScreen> {
Timer _timer;
int count = 3;
startTime() async {
//設(shè)置啟動(dòng)圖生效時(shí)間
var _duration = new Duration(seconds: 1);
new Timer(_duration, () {
// 空等1秒之后再計(jì)時(shí)
_timer = new Timer.periodic(const Duration(milliseconds: 1000), (v) {
count--;
if (count == 0) {
navigationPage();
} else {
setState(() {});
}
});
return _timer;
});
}
void navigationPage() {
_timer.cancel();
Navigator.of(context).pushReplacementNamed('/main');
}
@override
void initState() {
super.initState();
startTime();
}
@override
Widget build(BuildContext context) {
return new Stack(
alignment: const Alignment(1.0, -1.0), // 右上角對(duì)齊
children: [
new ConstrainedBox(
constraints: BoxConstraints.expand(),
child: new Image.asset(
"assets/images/ad.jpg",
fit: BoxFit.fill,
),
),
new Padding(
padding: new EdgeInsets.fromLTRB(0.0, 30.0, 10.0, 0.0),
child: new FlatButton(
onPressed: () {
navigationPage();
},
// padding: EdgeInsets.all(0.0),
color: Colors.grey,
child: new Text(
"$count 跳過廣告",
style: new TextStyle(color: Colors.white, fontSize: 12.0),
),
),
)
],
);
}
}
flutter 廣告頁-3秒讀數(shù)后或者點(diǎn)擊跳過廣告按鈕后跳轉(zhuǎn)
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
相關(guān)閱讀更多精彩內(nèi)容
- 023|決策時(shí)間:用戶思考了很久,又把商品放回去了,怎么辦? 什么是“決策時(shí)間”?消費(fèi)者的注意力時(shí)長越來越短,人們...
- 【蝴蝶效應(yīng)】 蝴蝶效應(yīng):上個(gè)世紀(jì)70年代,美國一個(gè)名叫洛倫茲的氣象學(xué)家在解釋空氣系統(tǒng)理論時(shí)說,亞馬遜雨林一只蝴蝶...
- “情是一路走過,愛是點(diǎn)點(diǎn)滴滴”,在8月4號(hào)的一次內(nèi)訓(xùn)溝通會(huì)上,賴元桂老師的這句話,引起了我很深的一個(gè)認(rèn)同,也有很深...
- 第二章 云家家傳武學(xué) 老人從屋子的一角挖出來了一個(gè)小箱子,箱子很普通卻給人一種古樸的感覺。 “爺爺,這是什么?” ...