Flatter IOS应用程序在打开时立即崩溃
我可以从Android studio构建IOS应用程序,它构建得很好。这可能是不相关的,但Android的构建和运行工作得非常完美。我使用命令pod repo update、pod update GOOGLESIGN和pod install使其工作Flatter IOS应用程序在打开时立即崩溃,ios,flutter,Ios,Flutter,我可以从Android studio构建IOS应用程序,它构建得很好。这可能是不相关的,但Android的构建和运行工作得非常完美。我使用命令pod repo update、pod update GOOGLESIGN和pod install使其工作 Launching lib/main.dart on iPhone 11 Pro Max in debug mode... log: Must be admin to run 'stream' command Script started, outp
Launching lib/main.dart on iPhone 11 Pro Max in debug mode...
log: Must be admin to run 'stream' command
Script started, output file is /dev/null
Script done, output file is /dev/null
Running pod install...
Running Xcode build...
Xcode build done. 167.8s
但在IOS应用程序打开后,它立即崩溃。以下是我的医生总结:
[✓] Flutter (Channel stable, v1.9.1+hotfix.2, on Mac OS X 10.14.4 18E226, locale en-US)
[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[✓] Xcode - develop for iOS and macOS (Xcode 11.2)
[✓] Android Studio (version 3.5)
[✓] VS Code (version 1.39.2)
[✓] Connected device (1 available)
这是我的密码:
import 'dart:async';
import 'package:qr_scanner/info.dart';
//import 'package:url_launcher/url_launcher.dart';
import 'package:flutter/material.dart';
import 'package:barcode_scan/barcode_scan.dart';
import 'package:flutter/services.dart';
import 'package:firebase_database/firebase_database.dart';
import 'package:intl/intl.dart';
import 'package:google_sign_in/google_sign_in.dart';
void main() => runApp(MaterialApp(
debugShowCheckedModeBanner: false,
home: HomePage(),
));
class HomePage extends StatefulWidget {
@override
HomePageState createState() {
return new HomePageState();
}
}
class HomePageState extends State<HomePage> {
String result = "Tap me to sign in!";
TextEditingController studID = new TextEditingController();
TextEditingController firstName = new TextEditingController();
TextEditingController lastName = new TextEditingController();
final DatabaseReference database = FirebaseDatabase.instance.reference();
String numEntries = "blah";
GoogleSignIn _googleSignIn = GoogleSignIn(scopes: ['email']);
bool _isLoggedIn = false;
void initState() {
super.initState();
if (_isLoggedIn) {
result = "Tap me to sign in!";
} else {
result = "Log in with your School Google account to continue.";
}
}
_login() async {
try {
await _googleSignIn.signIn();
if (_googleSignIn.currentUser.email.split('@')[1] == "***********") {
setState(() {
_isLoggedIn = true;
result = "Tap me to sign in!";
// result = _googleSignIn.currentUser.displayName;
});
} else {
_logout();
}
} catch (err) {
print(err);
}
}
_logout() {
_googleSignIn.signOut();
setState(() {
_isLoggedIn = false;
result = "Please log in with your School Google account to continue.";
// result = "Log in!";
});
}
// _launchURL( String result) async {
//// const url = result;
// if (await canLaunch(result)) {
// await launch(result);
// } else {
// throw 'Could not launch $result';
// }
// }
void writeData(String s, String id, String firstName, String lastName,
String qrResult, String condition) {
var now = new DateTime.now();
print(now.month.toString() +
"/" +
now.day.toString() +
"/" +
now.year.toString() +
" " +
DateFormat("H:m:s").format(now));
database.child(s).set({
'Timestamp': (now.month.toString() +
"/" +
now.day.toString() +
"/" +
now.year.toString() +
" " +
DateFormat("H:m:s").format(now)),
'Student ID': id,
'First Name': firstName,
'Last Name': lastName,
'Room Number': qrResult,
'Contition': condition,
});
}
void readNumEntries() {
database.child('numEntries').once().then((DataSnapshot snapshot) {
// return snapshot.value;
print('Data : ${snapshot.value}');
numEntries = snapshot.value.toString();
});
}
Future _scanQR() async {
print("yolo");
setState(() {
readNumEntries();
});
String id = "";
for (int x = 0; x < _googleSignIn.currentUser.email.length - 1; x++) {
String email = _googleSignIn.currentUser.email;
if (email.substring(x, x + 1) == "1" ||
email.substring(x, x + 1) == "2" ||
email.substring(x, x + 1) == "3" ||
email.substring(x, x + 1) == "4" ||
email.substring(x, x + 1) == "5" ||
email.substring(x, x + 1) == "6" ||
email.substring(x, x + 1) == "7" ||
email.substring(x, x + 1) == "8" ||
email.substring(x, x + 1) == "9" ||
email.substring(x, x + 1) == "0") {
id += email.substring(x, x + 1);
}
}
id = "11" + id;
String firstName = _googleSignIn.currentUser.displayName.split(" ")[0];
String lastName = _googleSignIn.currentUser.displayName.split(" ")[1];
print(id);
print(firstName);
print(lastName);
try {
LastRoom room = new LastRoom();
// room.writeContent("hi1!!!!");
String qrResult = await BarcodeScanner.scan();
String condition = "";
room.readContent().then((onValue) {
if (onValue == "Check in") {
condition = "Check Out";
} else {
condition = "Check in";
}
writeData((int.parse(numEntries) + 1).toString(), id, firstName,
lastName, qrResult, condition);
room.writeContent(condition);
setState(() {
// result = "https://docs.google.com/forms v35/d/e/1FAIpQLSeX5jxY2oSHea8C2VCmEEj7ZFYG7F7KuPRrX9QHUbXwBIdt_A/viewform?usp=pp_url&entry.693612192=$firstName&entry.1310158676=$lastName&entry.201368718=$id&entry.503158018=$qrResult";
// result = "https://docs.google.com/forms/d/e/1FAIpQLSeX5jxY2oSHea8C2VCmEEj7ZFYG7F7KuPRrX9QHUbXwBIdt_A/viewform?usp=pp_url&entry.201368718=$id&entry.503158018=$qrResult";
// _launchURL(result);
result = "All checked in!\nTap again to check in!";
database
.update({'numEntries': (int.parse(numEntries) + 1).toString()});
});
});
} on PlatformException catch (ex) {
if (ex.code == BarcodeScanner.CameraAccessDenied) {
setState(() {
// result = "Camera permission was denied";
});
} else {
setState(() {
// result = "Unknown Error $ex";
});
}
} on FormatException {
setState(() {
result = "Tap me to sign in!";
});
} catch (ex) {
setState(() {
// result = "Unknown Error $ex";
});
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Colors.redAccent,
title: Text("ZipScan"),
),
body:
Container(
decoration: new BoxDecoration(
gradient: LinearGradient(
// Where the linear gradient begins and ends
begin: Alignment.topLeft,
end: Alignment.bottomRight,
// Add one stop for each color. Stops should increase from 0 to 1
stops: [0.9, 0.901, 1],
colors: [
// Colors are easy thanks to Flutter's Colors class.
Colors.blueGrey[800],
Colors.blueGrey[800],
Colors.blueGrey[800],
],
),
),
child: Column(
children: <Widget>[
_isLoggedIn
? Row(
children: <Widget>[
Container(
margin:
const EdgeInsets.only(top: 10, left: 10, right: 10),
child: Image.network(
_googleSignIn.currentUser.photoUrl,
height: 80,
width: 80,
)),
Center(
child: Column(
children: <Widget>[
Text(_googleSignIn.currentUser.displayName,
style: new TextStyle(
fontSize: 15.0, fontWeight: FontWeight.bold, color: Colors.white)),
Container(
height: 50,
width: 150,
margin: const EdgeInsets.only(
top: 10, left: 10, right: 10),
decoration: new BoxDecoration(
gradient: LinearGradient(
// Where the linear gradient begins and ends
begin: Alignment.topLeft,
end: Alignment.bottomRight,
// Add one stop for each color. Stops should increase from 0 to 1
stops: [0.8, 0.801, 1],
colors: [
// Colors are easy thanks to Flutter's Colors class.
Colors.blueGrey[600],
Colors.redAccent,
Colors.redAccent,
],
),
borderRadius: new BorderRadius.only(
topLeft: const Radius.circular(20.0),
topRight: const Radius.circular(20.0),
bottomLeft: const Radius.circular(20.0),
bottomRight: const Radius.circular(20.0),
),
color: Colors.blueGrey[600],
),
child: InkWell(
onTap: _logout,
child: Center(
child: Text("Log Out?",
style: new TextStyle(
fontSize: 15.0,
fontWeight: FontWeight.bold)),
)
),
)
],
))
],
)
: Row(
children: <Widget>[
Container(
margin:
const EdgeInsets.only(top: 10, left: 10, right: 10),
child: Icon(
Icons.account_circle,
size: 80,
)),
Container(
height: 100,
width: 150,
margin:
const EdgeInsets.only(top: 10, left: 10, right: 10),
decoration: new BoxDecoration(
gradient: LinearGradient(
// Where the linear gradient begins and ends
begin: Alignment.topLeft,
end: Alignment.bottomRight,
// Add one stop for each color. Stops should increase from 0 to 1
stops: [0.8, 0.801, 1],
colors: [
// Colors are easy thanks to Flutter's Colors class.
Colors.blueGrey[600],
Colors.redAccent,
Colors.redAccent,
],
),
borderRadius: new BorderRadius.only(
topLeft: const Radius.circular(20.0),
topRight: const Radius.circular(20.0),
bottomLeft: const Radius.circular(20.0),
bottomRight: const Radius.circular(20.0),
),
color: Colors.blueGrey[600],
),
child: InkWell(
onTap: _login,
child: Center(
child: Text("Log In?",
style: new TextStyle(
fontSize: 15.0,
fontWeight: FontWeight.bold)),
)),
)
],
),
// Container(
// padding: EdgeInsets.all(5),
// margin: const EdgeInsets.only(top: 10, left: 10, right: 10),
//// width: MediaQuery.of(context).size.width-30,
// decoration: new BoxDecoration(
//// border: new Border.all(color: Colors.black, width: 0.5),
// borderRadius: new BorderRadius.only(
// topLeft: const Radius.circular(5.0),
// topRight: const Radius.circular(5.0),
// bottomLeft: const Radius.circular(5.0),
// bottomRight: const Radius.circular(5.0),
// ),
// color: Colors.grey[300],
// ),
// width: MediaQuery.of(context).size.width,
// child: Center(
// child: TextField(
// controller: FirstName,
// decoration: new InputDecoration(labelText: "First Name"),
// keyboardType: TextInputType.text,
// ),
// ),
// ),
// Container(
// padding: EdgeInsets.all(5),
// margin: const EdgeInsets.only(top: 10, left: 10, right: 10),
//// width: MediaQuery.of(context).size.width-30,
// decoration: new BoxDecoration(
//// border: new Border.all(color: Colors.black, width: 0.5),
// borderRadius: new BorderRadius.only(
// topLeft: const Radius.circular(5.0),
// topRight: const Radius.circular(5.0),
// bottomLeft: const Radius.circular(5.0),
// bottomRight: const Radius.circular(5.0),
// ),
// color: Colors.grey[300],
// ),
// width: MediaQuery.of(context).size.width,
// child: Center(
// child: TextField(
// controller: LastName,
// decoration: new InputDecoration(labelText: "Last Name"),
// keyboardType: TextInputType.text,
// ),
// ),
// ),
// Container(
// padding: EdgeInsets.all(5),
// margin: const EdgeInsets.only(top: 10, left: 10, right: 10),
//// width: MediaQuery.of(context).size.width-30,
// decoration: new BoxDecoration(
//// border: new Border.all(color: Colors.black, width: 0.5),
// borderRadius: new BorderRadius.only(
// topLeft: const Radius.circular(5.0),
// topRight: const Radius.circular(5.0),
// bottomLeft: const Radius.circular(5.0),
// bottomRight: const Radius.circular(5.0),
// ),
// color: Colors.grey[300],
// ),
// width: MediaQuery.of(context).size.width,
// child: Center(
// child: TextField(
// controller: studID,
// decoration: new InputDecoration(labelText: "Enter your ID"),
// keyboardType: TextInputType.number,
// ),
// ),
// ),
InkWell(
onTap: () {
_isLoggedIn ? _scanQR() : print("Log in!!");
},
// _scanQR,
child: Container(
padding: EdgeInsets.all(5),
margin: const EdgeInsets.only(top: 10, left: 10, right: 10),
// width: MediaQuery.of(context).size.width-30,
decoration: new BoxDecoration(
gradient: LinearGradient(
// Where the linear gradient begins and ends
begin: Alignment.topLeft,
end: Alignment.bottomRight,
// Add one stop for each color. Stops should increase from 0 to 1
stops: [0.85, 0.851, 1],
colors: [
// Colors are easy thanks to Flutter's Colors class.
Colors.blueGrey[600],
Colors.redAccent,
Colors.redAccent,
],
),
borderRadius: new BorderRadius.only(
topLeft: const Radius.circular(5.0),
topRight: const Radius.circular(5.0),
bottomLeft: const Radius.circular(5.0),
bottomRight: const Radius.circular(5.0),
),
color: Colors.blueGrey[600],
),
width: MediaQuery.of(context).size.width,
height: 300,
child: Center(
child: Text(
result,
style: new TextStyle(
fontSize: 30.0, fontWeight: FontWeight.bold),
),
)))
],
),
)
//backgroundColor: Colors.grey,
);
}
}
导入'dart:async';
导入“包装:qr_扫描仪/info.dart”;
//导入“package:url_launcher/url_launcher.dart”;
进口“包装:颤振/材料.省道”;
导入“包装:条形码扫描/条形码扫描.dart”;
导入“包:flifter/services.dart”;
导入“package:firebase_database/firebase_database.dart”;
导入“包:intl/intl.dart”;
导入“包:google_sign_in/google_sign_in.dart”;
void main()=>runApp(MaterialApp(
debugShowCheckedModeBanner:false,
主页:主页(),
));
类主页扩展了StatefulWidget{
@凌驾
HomePageState createState(){
返回新的HomePageState();
}
}
类HomePageState扩展了状态{
String result=“点击我登录!”;
TextEditingController studID=新的TextEditingController();
TextEditingController firstName=新的TextEditingController();
TextEditingController lastName=新的TextEditingController();
final DatabaseReference database=FirebaseDatabase.instance.reference();
字符串numEntries=“blah”;
谷歌签名(GoogleSignIn=GoogleSignIn(范围:['电子邮件']);
boolu isLoggedIn=false;
void initState(){
super.initState();
如果(_isLoggedIn){
结果=“点击我登录!”;
}否则{
result=“使用您的学校谷歌帐户登录以继续。”;
}
}
_login()异步{
试一试{
等待谷歌签名;
如果(_googleSignIn.currentUser.email.split('@')[1]==“**********”){
设置状态(){
_isLoggedIn=真;
结果=“点击我登录!”;
//结果=_googleSignIn.currentUser.displayName;
});
}否则{
_注销();
}
}捕捉(错误){
打印(错误);
}
}
_注销(){
_googleSignIn.signOut();
设置状态(){
_isLoggedIn=false;
结果=“请使用您的学校谷歌帐户登录以继续。”;
//结果=“登录!”;
});
}
//\u启动URL(字符串结果)异步{
////const url=结果;
//如果(等待canLaunch(结果)){
//等待发射(结果);
//}其他{
//抛出“无法启动$result”;
// }
// }
void writeData(字符串s、字符串id、字符串firstName、字符串lastName、,
字符串(结果、字符串条件){
var now=new DateTime.now();
打印(now.month.toString()+
"/" +
now.day.toString()+
"/" +
now.year.toString()+
" " +
日期格式(“H:m:s”)。格式(现在);
database.child.set({
'Timestamp':(now.month.toString()+
"/" +
now.day.toString()+
"/" +
now.year.toString()+
" " +
DateFormat(“H:m:s”).format(现在)),
“学生ID”:ID,
“名字”:名字,
“姓氏”:姓氏,
“房间号”:结果,
“继续”:条件,
});
}
void readNumEntries(){
database.child('numEntries').once().then((DataSnapshot快照){
//返回snapshot.value;
打印('Data:${snapshot.value}');
numEntries=snapshot.value.toString();
});
}
Future\u scanQR()异步{
印刷品(“约罗”);
设置状态(){
读物();
});
字符串id=“”;
对于(int x=0;x<_googleSignIn.currentUser.email.length-1;x++){
字符串email=\u googlesign.currentUser.email;
如果(email.substring(x,x+1)=“1”||
email.substring(x,x+1)=“2”||
email.substring(x,x+1)=“3”||
email.substring(x,x+1)=“4”||
email.substring(x,x+1)=“5”||
email.substring(x,x+1)=“6”||
email.substring(x,x+1)=“7”||
email.substring(x,x+1)=“8”||
email.substring(x,x+1)=“9”||
电子邮件。子字符串(x,x+1)=“0”){
id+=email.substring(x,x+1);
}
}
id=“11”+id;
字符串firstName=_googleSignIn.currentUser.displayName.split(“”[0];
字符串lastName=_googleSignIn.currentUser.displayName.split(“”[1];
打印(id);
印刷品(名字);
印刷品(姓氏);
试一试{
LastRoom=新的LastRoom();
//room.writeContent(“hi1!!!!”);
String qrResult=Wait BarcodeScanner.scan();
字符串条件=”;
room.readContent().then((onValue){
如果(onValue==“签入”){
条件=“签出”;
}否则{
条件=“签入”;
}
writeData((int.parse(numEntries)+1).toString(),id,firstName,
姓氏、结果、条件);
房间。书面内容(条件);
设置状态(){
//结果=”https://docs.google.com/forms v35/d/e/1FAIpQLSeX5jxY2oSHea8C2VCmEEj7ZFYG7F7KuPRrX9QHUbXwBIdt_A/viewform?usp=pp_url&entry.693612192=$firstName&entry.1310158676=$lastName&entry.201368718=$id&entry.503158018=$qrResult”;
//结果=”https://docs.google.com/forms/d/e/1FAIpQLSeX5jxY2oSHea8C2VCmEEj7ZFYG7F7KuPRrX9QHUbXwBIdt_A/viewform?usp=pp_url&entry.201368718=$id&entry.503158018=$qrResult”;
//_启动URL(结果);
结果=“全部签入!\n再次映射以签入!”;
数据库
.update({'numEntries':(int.parse(numEntries)+1.toString()});
});
});
}平台上异常捕获(ex){
if(ex.code==BarcodeScanner.CameraAccessDenied){
设置状态(){
//结果=“摄像机权限被拒绝”;
});
}否则{
设置状态(){
//结果=“未知错误$ex”;
});
}
}论格式例外{
设置状态(){
结果=“点击我登录!”;
});
}捕获(ex){
设置状态(){
//结果
sudo mkdir -p /foo/bin
sudo cp /usr/bin/log /foo/bin
sudo chmod u+s /foo/bin/log
return runCommand(<String>[
'script', '/dev/null', '/usr/bin/log', 'stream', '--style', 'syslog', '--predicate', 'processImagePath CONTAINS "${device.id}"',
]);
return runCommand(<String>[
'script', '/dev/null', '/foo/bin/log', 'stream', '--style', 'syslog', '--predicate', 'processImagePath CONTAINS "${device.id}"',
]);