import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/services.dart'; import 'package:flutter_screenutil/screenutil.dart'; import 'package:flutter_swiper/flutter_swiper.dart'; import 'package:ysairplane2/code/YSTabbar.dart'; import 'package:ysairplane2/tools/YSNetWorking.dart'; import 'package:ysairplane2/tools/YSTools.dart'; class YSWelcome extends StatefulWidget { @override _YSWelcomeState createState() => _YSWelcomeState(); } class _YSWelcomeState extends State { List _images = ['lib/images/1.png','lib/images/2.png','lib/images/3.png']; @override void initState() { Future.delayed(Duration(seconds: 0)).then((value){ _getPrivacyAgreement(); }); super.initState(); } _getPrivacyAgreement() async{ ScreenUtil.init(context,designSize: Size(750, 1624),allowFontScaling: false); var dict = await ysRequestHttp(context, type: requestType.get, api: '/app/applets/dic/dtDic/getPrivacyAgreement', parameter: {},isLoading: false); if(dict!=null){ showAgreeAlert(context,title: '用户协议与隐私政策',content: dict['data']['value'],agree: (value){ if(value==false){ SystemChannels.platform.invokeMethod('SystemNavigator.pop'); }else{ Navigator.pop(context); } },isWelcome: true); } } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.white, body: Container( height: MediaQuery.of(context).size.height, width: MediaQuery.of(context).size.width, child: Swiper( itemBuilder: (BuildContext context, int index) { return Stack( children: [ Image( height: MediaQuery.of(context).size.height, width: MediaQuery.of(context).size.width, fit: BoxFit.fill, image: AssetImage(_images[index]), ), if(index==_images.length-1)GestureDetector( onTap: (){ Navigator.of(context).pushAndRemoveUntil( CupertinoPageRoute( builder: (context){ return YSTabbar(); } ),(route) => false); }, child: Container( margin: EdgeInsets.only(top: MediaQuery.of(context).size.height-60,left: MediaQuery.of(context).size.width/2-50), height: 35, width: 100, decoration: BoxDecoration( color: Color(0xFF3676EC), borderRadius: BorderRadius.all(Radius.circular(50)) ), alignment: Alignment.center, child: Text('立即体验',style: TextStyle(color: Colors.white,fontSize: 14,fontWeight: FontWeight.bold),), ), ) ], ); }, itemCount: _images.length, scrollDirection: Axis.horizontal, loop: false, duration: 300, autoplay: false, pagination: SwiperPagination( alignment: Alignment.bottomCenter, builder: DotSwiperPaginationBuilder( color: Color(0xFCE1E1E1), activeColor: Color(0xFF3676EC), size: 5.0, activeSize: 10.0, ), margin: EdgeInsets.only(bottom: 80) ), autoplayDisableOnInteraction : true, ), ), ); } }