How to pass data from php to get information, i try calling it but it show null in Flutter. First, I have a database and have code and also have php file to get infomation. I am using inkscape to create a barcode to scan it.
For example , I create barcode that contain 'P002',and databse also have the code. But i scan from it ,they show null in debug console Flutter.
This example from flutter ,i try to call
Future<Product> getProduct()async{
await http.get("https://smileylion.com/easyshopping/php/getproduct.php?code=${widget.code}",)
.then((response){
if(jsonDecode(response.body)!=null){
setState(() {
product = Product.fromJson(jsonDecode(response.body));
});
}
});
return product;
}
My questions ,how to pass the data and not show null ?
Is the API you use public? If that is the case, try consuming the endpoint you mentioned:
https://smileylion.com/easyshopping/php/getproduct.php?code=POO2
and this returns null, therefore it is a problem of the backend (database or services) not of flutter.