Fix For iOS

This commit is contained in:
2022-04-10 16:19:54 +08:00
parent a95036f8cf
commit bb932e34cb
10 changed files with 75 additions and 229 deletions
+2 -2
View File
@@ -176,7 +176,7 @@ class UserInfo {
};
//若list[i]为'',解密时会报错:aes decode error:RangeError: Value not in range: -16
String thisAndroidId = ''; //每个手机唯一的设备号
String thisDeviceId = ''; //每个手机唯一的设备号
String username = '';
String password = '';
String userLoginInfo = '';
@@ -184,7 +184,7 @@ class UserInfo {
Map userRulesMap = {}; //用户所属组的权限列表
String getUserinfoEncrypted2() {
String userinfoEncrypted1 = EncryptUtil.aesEncode(thisAndroidId) +
String userinfoEncrypted1 = EncryptUtil.aesEncode(thisDeviceId) +
'\n' +
EncryptUtil.aesEncode(username) +
'\n' +
+9 -5
View File
@@ -273,12 +273,16 @@ Future<Map> getMapFromJson(var response) async {
// );
// }
Future<String> getAndroidId() async {
Future<String> getDeviceId() async {
DeviceInfoPlugin deviceInfo = DeviceInfoPlugin();
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
//print('每个手机唯一的设备号:${androidInfo.androidId}'); // e.g. "Moto G (4)"
g_userInfo.thisAndroidId = androidInfo.androidId;
return g_userInfo.thisAndroidId;
if (Platform.isAndroid) {
AndroidDeviceInfo androidInfo = await deviceInfo.androidInfo;
return androidInfo.androidId;
} else if (Platform.isIOS) {
return (await deviceInfo.iosInfo).identifierForVendor;
}
assert(false, 'Unsupported Platform');
return '';
}
// void playOrPause() {
+18 -16
View File
@@ -19,22 +19,24 @@ checkPermission() {
//整个Flutter App的入口03
bool ret = await getPermission();
if (ret) {
//整个Flutter App的入口04
getSDCardDir().then((value) {
//整个Flutter App的入口05
//runApp(MyApp());
runApp(MaterialApp(
//title: '启动图demo',
debugShowCheckedModeBanner: false,
theme: new ThemeData(
brightness: Brightness.light,
backgroundColor: Colors.white,
platform: TargetPlatform.android),
home: new SplashScreen(), //整个Flutter App的入口06
//整个Flutter App的入口07
routes: <String, WidgetBuilder>{'/home': (BuildContext context) => MyApp()},
));
});
var app = runApp(MaterialApp(
debugShowCheckedModeBanner: false,
theme: new ThemeData(
brightness: Brightness.light,
backgroundColor: Colors.white,
platform: TargetPlatform.android),
home: new SplashScreen(),
routes: <String, WidgetBuilder>{
'/home': (BuildContext context) => MyApp()
},
));
if (Platform.isAndroid) {
getSDCardDir().then((value) {
app;
});
} else if (Platform.isIOS) {
app;
}
} else {
Fluttertoast.showToast(msg: '用户未授权,程序无法正常运行!', gravity: ToastGravity.CENTER);
SystemChannels.platform.invokeMethod('SystemNavigator.pop');
+8 -86
View File
@@ -29,32 +29,13 @@ void main() {
WidgetsFlutterBinding.ensureInitialized(); //必须要添加这个进行初始化 否则下面会错误
//Flutter 强制竖屏
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp, // 纵向,portrait 肖像
// DeviceOrientation.portraitDown, // 旋转180度
// DeviceOrientation.landscapeLeft, //顺时针旋转90度
// DeviceOrientation.landscapeRight, //逆时针旋转90度
DeviceOrientation.portraitUp,
]).then((_) {
//整个Flutter App的入口02
checkPermission(); //请求用户授权
});
}
// class LoadMyApp extends StatefulWidget {
// LoadMyApp({Key key}) : super(key: key);
//
// _LoadMyAppState createState() => _LoadMyAppState();
// }
//
// class _LoadMyAppState extends State<LoadMyApp> {
// @override
// Widget build(BuildContext context) {
// return new MaterialApp(
// //title: "LoadActivity",
// home: MyApp(),
// );
// }
// }
//整个Flutter App的入口07。入口处理结束,正式开始Flutter App
class MyApp extends StatefulWidget {
MyApp({Key key}) : super(key: key);
@@ -81,28 +62,19 @@ class _MyAppState extends State<MyApp> {
print('version = $version');
print('buildNumber = $buildNumber');
print('buildDate = $buildDate');
// I/flutter (30820): appName = 宜宾市翠屏黑烟抓拍
// I/flutter (30820): packageName = com.flutter.hyzp_ybqx
// I/flutter (30820): version = 1.3.1
// I/flutter (30820): buildNumber = 20210508
// I/flutter (30820): buildDate = 2021.05.08
//Fluttertoast.showToast(msg: '当前版本 v$version。暂无更新', gravity: ToastGravity.CENTER);
// Navigator.of(context).push(MaterialPageRoute(
// builder: (context) => MyUpdated(ver: version, date: buildDate, theContext: context)));
MyUpdatedNew m = await MyUpdatedNew(
ver: version, date: buildDate, theContext: context, bStartUpdated: true);
await MyUpdatedNew(
ver: version,
date: buildDate,
theContext: context,
bStartUpdated: true);
});
super.initState();
}
void initApp() async {
// await getFileName2().then((value) {
// readUrlFile2().then((value) => writeUrlFile2());
// });
getAndroidId().then((value) {
g_userInfo.thisAndroidId = value;
getDeviceId().then((value) {
g_userInfo.thisDeviceId = value;
// 百度地图sdk初始化鉴权
if (Platform.isIOS) {
@@ -122,22 +94,6 @@ class _MyAppState extends State<MyApp> {
eventBus.fire(VoiceRemindUpdate('g_bVoiceRemind 数据已更新'));
}
//@override
// Widget build(BuildContext context) {
// return ScreenUtilInit(
// designSize: Size(360, 690),
// allowFontScaling: false,
// builder: () => MaterialApp(
// debugShowCheckedModeBanner: false,
// title: 'Flutter_ScreenUtil',
// theme: ThemeData(
// primarySwatch: Colors.blue,
// ),
// home: HomePage(title: 'FlutterScreenUtil Demo'),
// ),
// );
// }
@override
Widget build(BuildContext context) {
//ScreenUtil.instance = ScreenUtil(width: 750, height: 1334)..init(context);
@@ -184,28 +140,6 @@ class _MyAppState extends State<MyApp> {
),
),
);
// return MultiProvider(
// providers: [
// // ChangeNotifierProvider(builder: (_) => Counter()),
// // ChangeNotifierProvider(builder: (_) => Cart()),
// // ChangeNotifierProvider(builder: (_) => CheckOut()),
// // ChangeNotifierProvider(builder: (_) => PlayerRegionProvide()),
// // ChangeNotifierProvider(builder: (_) => PlayerRatioProvide()),
// ChangeNotifierProvider<PlayerRegionProvide>(create: (context) => PlayerRegionProvide()),
// ChangeNotifierProvider<PlayerRatioProvide>(create: (context) => PlayerRatioProvide()),
// ],
//
// child: MaterialApp(
// home: LoginTabs(),
// debugShowCheckedModeBanner: false,
// initialRoute: '/',
// onGenerateRoute: onGenerateRoute,
// theme: ThemeData(
// // primaryColor: Colors.yellow
// primaryColor: Colors.white),
// ),
// );
}
}
@@ -235,18 +169,6 @@ class _SplashScreenState extends State<SplashScreen> {
@override
Widget build(BuildContext context) {
// return new Scaffold(
// body: new Center(
// child: new Image.asset('assets/images/hyzp_yibin_launche.png', fit: BoxFit.fill),
// // child: new Image.asset('assets/images/hyzp_ybqx01_cuiping_launche.png'),
// ),
// );
// return Container(
// width: MediaQuery.of(context).size.width, // 屏幕宽度
// height: MediaQuery.of(context).size.height, // 屏幕高度
// child: Image.asset('assets/images/hyzp_yibin_launche.png', fit: BoxFit.cover),
// );
//final double statusBarHeight = MediaQuery.of(context).padding.top;
return Scaffold(
body: Column(
children: <Widget>[
+9 -25
View File
@@ -129,12 +129,7 @@ class _LoginPageState extends State<FaceLogin2> {
),
),
),
onTap: () {
if (!bMayLogin) {
return;
}
Navigator.pushNamed(context, '/faceLogin_take_pictuer', arguments: 'FaceLogin');
},
onTap: faceLogin,
),
SizedBox(height: ScreenUtil().setHeight(40)),
Container(
@@ -150,12 +145,7 @@ class _LoginPageState extends State<FaceLogin2> {
),
SizedBox(height: ScreenUtil().setHeight(20)),
InkWell(
onTap: () {
if (!bMayLogin) {
return;
}
Navigator.pushNamed(context, '/faceLogin_take_pictuer', arguments: 'FaceLogin');
},
onTap: faceLogin,
child: Container(
alignment: Alignment(0, 0),
margin: EdgeInsets.all(5),
@@ -170,19 +160,6 @@ class _LoginPageState extends State<FaceLogin2> {
),
),
),
// JdButton(
// height: 126,
// //JdText中已经使用ScreenUtil().setHeight(126),此处不能传 ScreenUtil().setHeight(126) ,否则严重错位
// width: 999,
// text: "开始检测",
// color: Color.fromRGBO(23, 176, 91, 1),
// onTop: () {
// if (!bMayLogin) {
// return;
// }
// Navigator.pushNamed(context, '/faceLogin_take_pictuer', arguments: 'FaceLogin');
// },
// ),
],
),
),
@@ -237,4 +214,11 @@ class _LoginPageState extends State<FaceLogin2> {
],
);
}
faceLogin() async {
if (!bMayLogin) {
return;
}
Navigator.pushNamed(context, '/faceLogin_take_pictuer', arguments: 'FaceLogin');
}
}
+18 -56
View File
@@ -1,3 +1,5 @@
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
@@ -37,7 +39,7 @@ class LoginTabs2State extends State<LoginTabs2> {
Container(
height: ScreenUtil().screenHeight -
ScreenUtil().statusBarHeight -
ScreenUtil().bottomBarHeight,
(Platform.isAndroid ? ScreenUtil().bottomBarHeight : 0),
width: ScreenUtil().screenWidth,
decoration: BoxDecoration(
image: DecorationImage(
@@ -54,15 +56,21 @@ class LoginTabs2State extends State<LoginTabs2> {
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
IconButton(
onPressed: () {
//Navigator.pop(context);
SystemNavigator.pop(); //退出App
},
icon: const Icon(Icons.close, color: Colors.white),
)
],
children: (() {
if (Platform.isAndroid) {
return [
IconButton(
onPressed: () {
//Navigator.pop(context);
SystemNavigator.pop(); //退出App
},
icon:
const Icon(Icons.close, color: Colors.white),
)
];
}
return <Widget>[];
})(),
),
),
Center(
@@ -113,10 +121,6 @@ class LoginTabs2State extends State<LoginTabs2> {
color: Colors.transparent,
height: ScreenUtil().setHeight(130), //不能超过133,否则有些手机会越界
child: Text(
//'© 宜宾市翠屏生态环境局\n© 四川省踏石科技有限公司 版权所有 \n服务热线:187-8467-8300',
//'© 宜宾市翠屏生态环境局\n© 四川省踏石科技有限公司',
//'© 宜宾市翠屏生态环境局 四川省踏石科技 版权所有\n服务热线:187-8467-8300',
//'© 宜宾市翠屏生态环境局 版权所有',
copyright_info,
maxLines: 2,
textAlign: TextAlign.center,
@@ -126,48 +130,6 @@ class LoginTabs2State extends State<LoginTabs2> {
fontWeight: FontWeight.bold),
),
),
//144
// 384
// 36
// 166
// 17
// 1026
// 1573
// 1768
//S7采用5.1英寸的Super AMOLED屏幕,分辨率为2560 ×1440(Quad HD),设置为1920*1080
// Wrap(
// runSpacing: 9.0,
// alignment: WrapAlignment.center,
// children: <Widget>[
// Row(
// crossAxisAlignment: CrossAxisAlignment.center,
// mainAxisAlignment: MainAxisAlignment.center,
// children: <Widget>[
// Text('${pageData['title']}',
// style: TextStyle(fontSize: 38.0, color: Color.fromRGBO(234, 200, 134, 1)))
// ],
// ),
// //自定义圆角
// ClipRRect(
// borderRadius: BorderRadius.circular(12.5),
// child: Container(
// height: 25.0,
// width: 190.0,
// color: Color.fromRGBO(234, 200, 134, 1),
// child: Row(
// crossAxisAlignment: CrossAxisAlignment.center,
// mainAxisAlignment: MainAxisAlignment.center,
// children: <Widget>[
// Text(
// '${pageData['subTitle']}',
// textAlign: TextAlign.center,
// style: TextStyle(color: Color.fromRGBO(113, 80, 24, 1)),
// )
// ])))
// ],
// )
],
),
),
+2 -19
View File
@@ -59,25 +59,6 @@ class MyUpdatedNew {
registerCallback({bool first = false}) {
//3、在initState中初始化
/*
D/DownloadWorker( 4745): Update too frequently!!!!, this should be dropped
E/flutter ( 4745): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: NoSuchMethodError: The method 'update' was called on null.
E/flutter ( 4745): Receiver: null
E/flutter ( 4745): Tried calling: update(message: "下载中,请稍后…", progress: 0.0)
E/flutter ( 4745): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
E/flutter ( 4745): #1 MyUpdatedNew._updateDownLoadInfo (package:hyzp_ybqx/pages/MyMsics/05_updated/MyUpdatedNew.dart:251:10)
E/flutter ( 4745): #2 _rootRunUnary (dart:async/zone.dart:1206:13)
E/flutter ( 4745): #3 _CustomZone.runUnary (dart:async/zone.dart:1100:19)
E/flutter ( 4745): #4 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7)
E/flutter ( 4745): #5 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:357:11)
E/flutter ( 4745): #6 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:285:7)
E/flutter ( 4745): #7 _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:808:19)
E/flutter ( 4745): #8 _StreamController._add (dart:async/stream_controller.dart:682:7)
E/flutter ( 4745): #9 _StreamController.add (dart:async/stream_controller.dart:624:5)
E/flutter ( 4745): #10 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
E/flutter ( 4745):
*/
if (!first) {
// 解决2次进入报错无法下载的问题-OK
// 如果以前注册过必须先移除,否则报错无法下载:DownloadWorker( 4745): Update too frequently!!!!, this should be dropped
@@ -128,6 +109,8 @@ class MyUpdatedNew {
_showNoNewVersionAppDialog();
}
});
} else if (Platform.isIOS) {
// TODO: iOS更新
}
}
+8 -4
View File
@@ -207,10 +207,6 @@ class _Page4_MyMsicsNewState extends State<Page4_MyMsicsNew>
leadColor: _greenColor,
onTapFun: OnTap_MyUpdate,
bBadge: bNewVer),
_getListTile('软件下载',
leadPath: 'assets/images/download.png',
leadColor: _deepBlueColor,
onTapFun: OnTap_download),
_getListTile('待审提醒',
leadPath: 'assets/images/语音提醒.png',
leadColor: _deepGreyColor,
@@ -229,6 +225,14 @@ class _Page4_MyMsicsNewState extends State<Page4_MyMsicsNew>
// leadColor: _deepGreyColor,
// onTapFun: OnTap_UserAuthority),
];
if (Platform.isAndroid) {
_listViewUser.insert(
3,
_getListTile('软件下载',
leadPath: 'assets/images/download.png',
leadColor: _deepBlueColor,
onTapFun: OnTap_download));
}
}
//已添加管理员记录的标志,0 未添加, 1 已添加 1 次