map_view => NoSuchMethodError flutter

After update flutter I have this error bellow, only when I erase app and release a new app. If I just hot reload I havn't this error and map is launch correctly.
I'm certain it's was after update flutter. I saved each blocs validations, and now this issue is repeatable with all previous backup, and I certain that I validate this fonction after remove and reinstall app



in libobject_patch.dart

@patch
dynamic noSuchMethod(Invocation invocation) {
// TODO(regis): Remove temp constructor identifier 'withInvocation'.
throw new NoSuchMethodError.withInvocation(this, invocation);
}




in the console

E/flutter (28250): [ERROR:topaz/lib/tonic/logging/dart_error.cc(16)] Unhandled exception:
E/flutter (28250): NoSuchMethodError: The method 'substring' was called on null.
E/flutter (28250): Receiver: null
E/flutter (28250): Tried calling: substring(1, 10)
E/flutter (28250): #0 Object.noSuchMethod (dart:core/runtime/libobject_patch.dart:46:5)
E/flutter (28250): #1 _ContentState.initState.<anonymous closure> (file:///C:/Users/utilisateur/Desktop/nirbiapp/lib/Content.dart:145:40)
E/flutter (28250): #2 _RootZone.runUnaryGuarded (dart:async/zone.dart:1316:10)
E/flutter (28250): #3 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:330:11)
E/flutter (28250): #4 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:257:7)
E/flutter (28250): #5 _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:132:11)
E/flutter (28250): #6 _MapStream._handleData (dart:async/stream_pipe.dart:232:10)
E/flutter (28250): #7 _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:164:13)
E/flutter (28250): #8 _RootZone.runUnaryGuarded (dart:async/zone.dart:1316:10)
E/flutter (28250): #9 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:330:11)
E/flutter (28250): #10 _DelayedData.perform (dart:async/stream_impl.dart:578:14)
E/flutter (28250): #11 _StreamImplEvents.handleNext (dart:async/stream_impl.dart:694:11)
E/flutter (28250): #12 _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:654:7)
E/flutter (28250): #13 _microtaskLoop (dart:async/schedule_microtask.dart:41:21)
E/flutter (28250): #14 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)




flutter doctor

C:\flutter\bin\flutter.bat --no-color doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel beta, v0.4.4, on Microsoft Windows [version
10.0.16299.431], locale fr-FR)
[√] Android toolchain - develop for Android devices (Android SDK 27.0.3)
[√] Android Studio (version 3.0)
[√] VS Code, 64-bit edition (version 1.21.1)
[√] Connected devices (1 available)

• No issues found!
Process finished with exit code 0




I have this error when I place showMap here:

_loadgeoValue() async {

SharedPreferences prefs = await SharedPreferences.getInstance();
setState(() {

lat = (prefs.getDouble('lat'));
long = (prefs.getDouble('long'));

});

showMap();

}




If I launch showMap(); after Onpressed Button I have no issues.
but if I do that, I don't know how to update map with lat and long variable.

Currently I launch the map when I receive sms with coordinate, for this ,

1/ I send sms with Onpressed button

2/ I read the reply with : SmsReceiver().onSmsReceived.listen((SmsMessage msg)

3/ I extract coordinate (lat long) with regex

4/ I save values with shared preference

5/ After saved, I launch mapview with the lat and long coordinate

I have replace if (msg.address == "+33$nirbinumber1") by my own number to test and to be certain of the achievement of the comparaison. Tried calling: substring(1, 10) is remove with the other lines but I have always libobject_patch.dart who is display

Here is the code with substring(1, 10)

String nirbinumber ;

loadnirbinumber() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
setState(() {
nirbinumber = (prefs.getString('number1'));
});
}

@override
void initState() {
super.initState();

loadnirbinumber(); //function to read programed number


new SmsReceiver().onSmsReceived.listen((SmsMessage msg) { // function to listen entry sms
var nirbinumber1= nirbinumber.substring(1, 10); //function to extract first number 0X XX XX XX XX

if (msg.address == "+33$nirbinumber1") // Action after compare input sms with programed number +33X XX XX XX XX
{
setState(() {
_lastMessage = msg;

});

RegExp regExp = new RegExp( //Here is the regex function to isolate first word of sms
r"^([\w\-]+)",
);
var match = regExp.firstMatch(_lastMessage.body);
group1 = match.group(1);

if ( group1 =="maps"){

MapView.setApiKey('AIzaSyCNYMslm35FPWYFGkJVMk7aAOd174TUCGQ');

_savegeoValue(); // this function use shared preference to save, extract, and load map
}
}
}
);
}




I replace by regex, it remove the substring error but no the noSuchMethode

new SmsReceiver().onSmsReceived.listen((SmsMessage msg) {

RegExp regExp = new RegExp(
r"^0([0-9]{9})",
);
var match = regExp.firstMatch(nirbinumber);
group1 = match.group(1);

if (msg.address == "+33$group1") {

setState(() {
_lastMessage = msg;

});

Comments

Popular posts from this blog

Meaning of `{}` for return expression

Get current scroll position of ScrollView in React Native

flutter websocket connection issue