flutter 网络请求以及数据处理
网络请求使用FutureBuilder来处理
import 'dart:convert';
Widget build(BuildContext context) {
return FutureBuilder(
future: httpReq.get(sevicePath['homeArticle']+'${widget.id}'),
builder: (context,snapshot){
if (snapshot.hasData){
var data = jsonDecode(snapshot.data.toString());
datas = (data['data'] as List).cast();
return SingleChildScrollView(
child: _cellList(),
);
}else{
return Center(
child: Text('加载中...'),
);
}
},
);
}