我有一个在Android / Web上正常运行的颤音应用程序,但是当我尝试在iOS模拟器中运行时,加载Google Maps时会崩溃。我正在运行MacPro -M1芯片btw ....
这是颤抖的医生输出 -
[✓] Flutter (Channel stable, 2.10.5, on macOS 12.3.1 21E258 darwin-arm, locale en-US)
• Flutter version 2.10.5 at /Users/wizeguy/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 5464c5bac7 (2 months ago), 2022-04-18 09:55:37 -0700
• Engine revision 57d3bac3dd
• Dart version 2.16.2
• DevTools version 2.9.2
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
• Android SDK at /Users/wizeguy/Library/Android/sdk
• Platform android-32, build-tools 32.1.0-rc1
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.3.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
I have a flutter app that works fine on android / web but when i try to run in IOS simulator it crashes when i load google maps. I'm running the macpro-m1 chip btw....
Here is the flutter doctor output -
[✓] Flutter (Channel stable, 2.10.5, on macOS 12.3.1 21E258 darwin-arm, locale en-US)
• Flutter version 2.10.5 at /Users/wizeguy/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 5464c5bac7 (2 months ago), 2022-04-18 09:55:37 -0700
• Engine revision 57d3bac3dd
• Dart version 2.16.2
• DevTools version 2.9.2
[✓] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
• Android SDK at /Users/wizeguy/Library/Android/sdk
• Platform android-32, build-tools 32.1.0-rc1
• Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 13.3.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
???? https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
???? https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
[✓] Connected device (2 available)
• iPod touch (7th generation) (mobile) • B9CD8BF0-2F3C-49D6-A73F-F4BAE6ED2EF5 • ios •
com.apple.CoreSimulator.SimRuntime.iOS-15-4 (simulator)
• Chrome (web) • chrome • web-javascript • Google Chrome
102.0.5005.115
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
Here is the appdelegate setup --
import UIKit
import Flutter
import GoogleMaps
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GMSServices.provideAPIKey("abcdefghu123345") // <-- i have real key in my code
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
Here is the error logs from Android Studio --
[VERBOSE-2:ui_dart_state.cc(209)] Unhandled Exception: NoSuchMethodError: The method 'call' was called on null.
Receiver: null
Tried calling: call()
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:38:5)
#1 _PhoneNumberInput.sendSMS (package:juggy/screens/phoneNumberInput.dart:72:34)
<asynchronous suspension>
Lost connection to device.
Code Snippet --
sendSMS() async{
var data = convert.json.encode({
'number': "+1$phoneNumber",
});
var requestHeaders = {
'Content-type': 'application/json',
'Accept': 'application/json',
};
var url = Uri.parse(
'https://us-central1-sonic-strains.cloudfunctions.net/app/api/twilioVerifyandSendCode');
// Await the http get response, then decode the json-formatted response.
// we need to verify code via sms
// so just change the ui back if bad request
var response = await http.post(url, body: data, headers: requestHeaders);
if (response.statusCode == 200) {
print("");
print("");
print("");
print("");
print("Calling toggle pin field");
await widget.togglePinField();
print("Calling toggle map field");
return widget.toggleMapField();
} else {
print('Request failed with status: ${response.statusCode}.');
print("");
print("your error for the sendSMS");
print(response);
// show the error & change the ui back if bad request
}
}
Just to recap
-
The app on IOS does not load the map but on web , android, etc the map loads fine.
-
The function that inits the map is called sendSMS which sends a code to the user, after successful authentication a function called toggleMap() is fired which changes the UI.
-
I'm getting an error that says the sendSMS() was called on null. I looked into this on stack but nothing I found nothing relevant to my issue.
Here is the UI code that accepts the SMS prior to changing th UI to map view --
String validatePhone(number) {
RegExp PhoneRule =
RegExp(r'^\d{10}
}
@override
Widget build(BuildContext context) {
return Container(
height: MediaQuery.of(context).size.height -
MediaQuery.of(context).padding.top,
color: Theme.of(context).backgroundColor,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Center(
child: Form(
key: _key,
child: Column(
children: [
const Text(
'Juggy',
style: TextStyle(fontWeight: FontWeight.bold,
fontSize: 40,
color: Colors.teal),
),
SizedBox(width: 84, height: 90, child: GameWidget(game: game)),
Padding(
padding: const EdgeInsets.only(top: 30),
child: SizedBox(
width: 200,
height: 90,
child: TextFormField(
onChanged: (value){
setState((){
phoneNumber = value;
widget.changePhoneNumber(value);
});},
keyboardType: TextInputType.number,
maxLength: 10,
decoration: const InputDecoration(
labelText: 'Enter Phone Number',
border: OutlineInputBorder(),
),
controller: _phoneController,
validator: (value) {
if (validatePhone(value) == "") {
return null;
}
return phoneError;
},
),
),
),
Padding(
padding: const EdgeInsets.only(top: 10),
child: Column(children: [
Container(
height: isProcessing ? 45 : 40,
width: MediaQuery
.of(context)
.size
.width * 0.4,
child: ElevatedButton.icon(
onPressed: isProcessing
? null
: () async {
if (_key.currentState!.validate()) {
return sendSMS();
}
},
icon: const Icon(Icons.phone, size: 18),
label: isProcessing
? Container(
height: 30,
padding: EdgeInsets.only(left: 10),
child: CircularProgressIndicator(
color: Colors.white,
))
: const Text("Send Code"),
),
),
])
)
],
),
),
),
],
),
);
}
);
if (PhoneRule.hasMatch(number)) {
setState(() {
phoneError = '';
phoneNumber = number;
});
return phoneError;
} else {
setState(() {
phoneError = 'Enter Correct Phone Number';
});
return phoneError;
}
}
}
发布评论
评论(1)
更改
_phonenumberinput.sendsms
Change
_PhoneNumberInput.sendSMS
to