import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import '../../components/commonFun.dart'; import '../../services/Storage.dart'; import 'FaceLogin.dart'; import 'LoginByName2.dart'; // class LoginTabs extends StatelessWidget { // // This widget is the root of your application. // @override // Widget build(BuildContext context) { // //Flutter 强制竖屏 // SystemChrome.setPreferredOrientations([ // DeviceOrientation.portraitUp, //只能纵向 // DeviceOrientation.portraitDown, //只能纵向 // ]); // // return MaterialApp( // debugShowCheckedModeBanner: false, // title: 'Flutter Demo', // theme: ThemeData( // primarySwatch: Colors.blue, // visualDensity: VisualDensity.adaptivePlatformDensity, // ), // home: MyHomePage(title: 'Flutter Demo Home Page'), // ); // } // } class LoginTabs extends StatefulWidget { LoginTabs({Key key, this.title}) : super(key: key); final String title; @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State { @override void initState() { super.initState(); //若下面文件不存在, // /data/data/com.flutter.hyzp_ybqx/shared_prefs/FlutterSharedPreferences.xml // value为null, 会抛出异常: // [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: Invalid argument(s): The source must not be null // int.parse (dart:core-patch/integers_patch.dart:51:25) Storage.getString("tabs_index").then((value) { g_iIndex = (null == value) ? 0 : int.parse(value); }); } @override Widget build(BuildContext context) { return Container( decoration: BoxDecoration( image: DecorationImage( image: AssetImage("assets/images/背景图.png"), fit: BoxFit.cover, ), ), child: Container( width: double.infinity, height: 400, child: Container( constraints: BoxConstraints( minWidth: double.infinity, //最小宽度尽量取最大 maxHeight: 400 //最小高度为80 ), child: DefaultTabController( length: 2, child: Scaffold( //backgroundColor: Colors.transparent, appBar: AppBar( //backgroundColor: Colors.transparent, title: Text("宜宾市翠屏黑烟车电子抓拍系统"), leading: IconButton( icon: Icon(Icons.close), onPressed: () { SystemNavigator.pop(); }, ), centerTitle: true, bottom: TabBar( labelColor: Colors.blueAccent, unselectedLabelColor: Colors.black26, tabs: [Tab(text: "密码登录"), Tab(text: "刷脸登录")], ), ), body: TabBarView( //flutter tabbar禁止手势滑动-OK physics: new NeverScrollableScrollPhysics(), children: [ LoginByName2(), FaceLogin(), ], ), ), ), ), ), ); } }