Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhandled Exception: NoSuchMethodError: The getter "int variable" was called on null. E/flutter ( 2129): Receiver: null E/flutter ( 2129): Tried calling: "int variable" #171

Open
vinayvishnu725 opened this issue Feb 25, 2020 · 0 comments

Comments

@vinayvishnu725
Copy link

vinayvishnu725 commented Feb 25, 2020

am getting otp was called null why because i dono... could anybody suggest me

String otpvalue ;
String otpvalue1 = "1234";

void otpvalidateandsubmit() async {
if (otpvalidateandsave()) {
if (postResult.otp == otpvalue) {
Navigator.of(context).push(
MaterialPageRoute(builder: (context) => Home()),
);
}
}
}

and another page
is below

import 'dart:convert';
import 'dart:async';

import 'package:http/http.dart' as http;

class PostResult {
String status;
String message;
var otp;

PostResult({this.status, this.message, this.otp});

factory PostResult.createPostResult(Map<String, dynamic> object) {
return PostResult(
status: object['status'],
message: object['message'],
otp: object['otp'],

);

}
static Future connectToAPI(String name, String phone, String referal, String type) async {
String apiURL = "http://xx2.1xx.1.x:8xx0/api/user/register";
print(name + phone + referal + type);

var apiResult = await http.post(apiURL,headers:{"Content-Type": "application/json"}, body: json.encode({"name": name, "phone": phone, "referral_code":referal, "register_type":type}));

var jsonObject = json.decode(apiResult.body);
print(jsonObject);

return PostResult.createPostResult(jsonObject); 

}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant