Flutter 类型';int';不是类型为';字符串';颤振API 进口“包装:颤振/材料.省道”; 将“package:http/http.dart”导入为http; 导入“包:intl/intl.dart”; 导入“package:
类型';int';不是类型为';字符串';颤振APIFlutter 类型';int';不是类型为';字符串';颤振API 进口“包装:颤振/材料.省道”; 将“package:http/http.dart”导入为http; 导入“包:intl/intl.dart”; 导入“package:,flutter,dart,Flutter,Dart,类型';int';不是类型为';字符串';颤振API 进口“包装:颤振/材料.省道”; 将“package:http/http.dart”导入为http; 导入“包:intl/intl.dart”; 导入“package:shared_preferences/shared_preferences.dart”; 导入“包装:selon_mart/model/product_fecth_all.dart”; 进口“包装:selon_mart/payment/paym
进口“包装:颤振/材料.省道”;
将“package:http/http.dart”导入为http;
导入“包:intl/intl.dart”;
导入“package:shared_preferences/shared_preferences.dart”;
导入“包装:selon_mart/model/product_fecth_all.dart”;
进口“包装:selon_mart/payment/payment_pulsa.dart”;
导入“package:selon_mart/themes/font.dart”;
导入“package:selon_mart/util/api.dart”;
类ProductCoba扩展了StatefulWidget{
地图数据;
ProductCoba({Key,this.data});
@凌驾
_ProductCobaState createState()=>\u ProductCobaState();
}
类_ProductCobaState扩展状态{
列表_listProduk=[];
var Eurosis Format=新的数字格式货币(
地点:“欧盟”,
符号:“,
小数位数:0,
);
getPref()异步{
SharedReferences首选项=等待SharedReferences.getInstance();
设置状态(){
getProductListBarang();
});
}
选择int;
//Future\u getProductList()异步{
//试一试{
//var response=wait http.post(Env.product,body:{
//“客户”:“C000150”,
//“类别”:“DATA-TSEL”,
// });
//final body=jsonDecode(response.body);
//_listProduk.clear();
//如果(正文['status']=“ok”){
//打印(响应.正文);
//对于(变量i=0;i
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'package:intl/intl.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:selon_mart/model/product_fecth_all.dart';
import 'package:selon_mart/payment/payment_pulsa.dart';
import 'package:selon_mart/themes/fonts.dart';
import 'package:selon_mart/util/api.dart';
class ProductCoba extends StatefulWidget {
Map<String, dynamic> data;
ProductCoba({Key key, this.data});
@override
_ProductCobaState createState() => _ProductCobaState();
}
class _ProductCobaState extends State<ProductCoba> {
List<ProductALL> _listProduk = [];
var eurosInUSFormat = new NumberFormat.currency(
locale: "eu",
symbol: "",
decimalDigits: 0,
);
getPref() async {
SharedPreferences preferences = await SharedPreferences.getInstance();
setState(() {
getProductListBarang();
});
}
int selected;
// Future<Null> _getProductList() async {
// try {
// var response = await http.post(Env.product, body: {
// "customer": "C000150",
// "category": "DATA-TSEL",
// });
// final body = jsonDecode(response.body);
// _listProduk.clear();
// if (body['status'] == "ok") {
// print(response.body);
// for (var i = 0; i < body['data'].length; i++) {
// setState(() {
// ProductPulsa produk = ProductPulsa.fromJson(body['data'][i]);
// _listProduk.add(produk);
// print('get data reguler success');
// });
// }
// } else {
// print("Empty Result");
// }
// } catch (e) {
// print(e);
// }
// }
Future<Null> getProductListBarang() async {
print("Login");
try {
// _showLoading("Please Wait...");
SharedPreferences prefs = await SharedPreferences.getInstance();
return http.get(await Env().productfecthall()).then((response) {
print(response.body);
final body = jsonDecode(response.body);
_listProduk.clear();
if (body["code"] == 200 && body["status"] == "OK") {
print(response.body);
for (var i = 0; i < body['product_list'].length; i++) {
setState(() {
ProductALL produk = ProductALL.fromJson(body['product_list'][i]);
_listProduk.add(produk);
print('get data product success');
});
}
} else {
print("Empty Result");
// showDialog(
// barrierDismissible: false,
// context: context,
// builder: (BuildContext context) {
// return AlertDialog(
// title: Text(
// // body['data'],
// "Empty Result",
// style: ThemeFonts.textStyle500
// .copyWith(fontSize: 16, color: Colors.black),
// ),
// // content: Text("please Relogin"),
// // actions: <Widget>[
// // new RaisedButton(
// // child: Text('Ok'),
// // textColor: Colors.grey,
// // onPressed: () {
// // // Navigator.pop(context);
// // Navigator.of(context).pushReplacement(
// // new MaterialPageRoute(
// // builder: (_) {
// // return LoginScreen();
// // },
// // ),
// // );
// // },
// // ),
// // ],
// );
// },
// );
}
}).catchError((error) {
print(error);
});
} catch (e) {
print(e);
}
return null;
}
@override
void initState() {
super.initState();
getPref();
}
@override
Widget build(BuildContext context) {
return Container(
color: Colors.grey[300],
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Flexible(
child: Container(
padding: const EdgeInsets.all(5.0),
// width: 400,
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
child: ListView.builder(
// gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
// childAspectRatio: 7.7,
// crossAxisCount: 1,
// crossAxisSpacing: 2.0,
// ),
itemCount: _listProduk == null ? 0 : _listProduk.length,
itemBuilder: (BuildContext context, int index) {
return new Container(
child: new Center(
child: new Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
GestureDetector(
onTap: () {
print(_listProduk[index].product_id);
_pilihMetodePembayaran();
setState(() {
selected = index;
});
},
child: new Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(4.0),
side: index == selected
? BorderSide(color: Colors.red, width: 1.5)
: BorderSide(
color: Colors.transparent, width: 0),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Row(
children: <Widget>[
Padding(
padding: const EdgeInsets.fromLTRB(
10.0,
10.0,
0.0,
10.0,
),
child: new Text(
"${_listProduk[index].productDesc}",
style: TextStyle(
fontFamily: 'SFCompactText',
fontSize: 15.0,
color: Colors.black,
),
),
),
Padding(
padding: const EdgeInsets.all(5.0),
child: new Text(
"Rp ${eurosInUSFormat.format(_listProduk[index].price)}",
style: TextStyle(
fontFamily: 'SFCompactText',
fontSize: 15.0,
color: Colors.black,
),
),
),
],
),
// Padding(
// padding: const EdgeInsets.all(10.0),
// child: new Text(
// _listProduk[index].label,
// style: TextStyle(
// fontFamily: 'SFCompactText',
// fontSize: 15.0,
// color: Colors.black,
// ),
// ),
// ),
],
),
),
),
],
),
),
);
},
),
),
),
],
),
);
}
void _pilihMetodePembayaran() {
Navigator.of(context).pushReplacement(
new MaterialPageRoute(
builder: (_) {
return DetailPembayaranPulsa(
data: {
'produk': _listProduk[selected],
},
);
},
),
);
}
}
String Id, product_id, name, category, productDesc, productType, productCategory, product_owner_id, product_owner_name,product_owner_profession, product_owner_category,
product_owner_status, outlet_id, outlet_name,outlet_phone, outlet_email, outlet_address,outlet_province,
outlet_city, outlet_district, outlet_subdistrict, outlet_zipcode, outlet_longitude, outlet_latitude,outlet_status,
product_media_media_id, product_media_media_type, product_media_media_url, product_media_ceate_date, product_media_last_update, product_media_thumbnail_url,
description, stock_type, stock_qty, promo, discount, rating, create_date, lst_update;
int price;
ProductALL({
this.Id,
this.product_id,
this.name,
this.category,
this.product_owner_id,
this.product_owner_name,
this.product_owner_profession,
this.product_owner_category,
this.product_owner_status,
this.outlet_id,
this.outlet_name,
this.outlet_phone,
this.outlet_email,
this.outlet_address,
this.outlet_province,
this.outlet_city,
this.outlet_district,
this.outlet_subdistrict,
this.outlet_zipcode,
this.outlet_longitude,
this.outlet_latitude,
this.outlet_status,
this.product_media_media_id,
this.product_media_media_type,
this.product_media_media_url,
this.product_media_ceate_date,
this.product_media_last_update,
this.product_media_thumbnail_url,
this.description,
this.price,
this.stock_type,
this.stock_qty,
this.promo,
this.discount,
this.rating,
this.create_date,
this.lst_update,
});
factory ProductALL.fromJson(Map<String, dynamic> parsedJson) {
return ProductALL(
Id: parsedJson['Id'],
product_id: parsedJson['product_id'],
name: parsedJson['name'],
category: parsedJson['category'],
product_owner_id: parsedJson['product_owner']['id'],
product_owner_name: parsedJson['product_owner']['name'],
product_owner_profession: parsedJson['product_owner']['profession'],
product_owner_category: parsedJson['product_owner']['category'],
product_owner_status: parsedJson['product_owner']['status'],
outlet_id: parsedJson['outlet']['id'],
outlet_name: parsedJson['outlet']['name'],
outlet_phone: parsedJson['outlet']['phone'],
outlet_email: parsedJson['outlet']['email'],
outlet_address: parsedJson['outlet']['address'],
outlet_province: parsedJson['outlet']['province'],
outlet_city: parsedJson['outlet']['city'],
outlet_district: parsedJson['outlet']['district'],
outlet_subdistrict: parsedJson['outlet']['subdistrict'],
outlet_zipcode: parsedJson['outlet']['zipcode'],
outlet_longitude: parsedJson['outlet']['longitude'],
outlet_latitude: parsedJson['outlet']['latitude'],
outlet_status: parsedJson['outlet']['status'],
product_media_media_id: parsedJson['product_media']['media_id'],
product_media_media_type: parsedJson['product_media']['media_type'],
product_media_media_url: parsedJson['product_media']['media_url'],
product_media_thumbnail_url: parsedJson['product_media']['thumbnail_url'],
product_media_ceate_date: parsedJson['product_media']['ceate_date'],
product_media_last_update: parsedJson['product_media']['last_update'],
description: parsedJson['description'],
price: parsedJson['price'],
stock_type: parsedJson['stock_type'],
stock_qty: parsedJson['stock_qty'],
promo: parsedJson['promo'],
discount: parsedJson['discount'],
rating: parsedJson['rating'],
create_date: parsedJson['create_date'],
lst_update: parsedJson['lst_update'],
);
}
}