Reputation: 19
i am totally new to flutter and even coding so kindly help me and also put it in simple terms here is my model class
import 'dart:convert';
class LoginUserDataModel {
LoginUserDataModel({
required this.id,
required this.name,
required this.email,
required this.phoneNumber,
required this.password,
required this.address,
});
String id;
String name;
String email;
String phoneNumber;
String password;
String address;
factory LoginUserDataModel.fromJson(Map<String, dynamic> json) =>
LoginUserDataModel(
id: json["id"],
name: json["name"],
email: json["email"],
phoneNumber: json["phone_number"],
password: json["password"],
address: json["address"],
);
Map<String, dynamic> toJson() => {
"id": id,
"name": name,
"email": email,
"phone_number": phoneNumber,
"password": password,
"address": address,
};
}
I post the phone_number to php which intern gives me the row which has that variable and then i get in using the model class. i can see the json data when i print it but i want to save individual value in variables so i can use it later on
here is my post request where i post the phone number to php which gives me the row containig that phone number
Future loginWithMobile(String isoCode, String mobileNumber) async {
var url = 'http://192.168.1.5/server/login.php';
var data = {
"phone_number": mobileNumber,
};
http.Response res = await http.post(Uri.parse(url), body: data);
var details = json.decode(json.encode(res.body));
}
Upvotes: 1
Views: 356