我的 snapshot.data 为空。当我打印响应时,它显示检索到的数据。但 snapshot.data 仍然为空。
Future _getUsers() async {
var data = await http.post("http://10.0.2.2/Flutter/abreport.php", body: {
{
"date": mydt,
});
var jsonData = json.decode(data.body); //edited
print(jsonData); // the data is printing here
return jsonData;
}
}
FutureBuilder(
future: _getUsers(),
builder: (BuildContext context, AsyncSnapshot snapshot) {
debugPrint(snapshot.data);
if (snapshot.data == null) {
return Container(
child: Center(
child:Text("no data"),
)
);
} else {
//some code
}
)
Run Code Online (Sandbox Code Playgroud) 我有一个包含特定日期的数组。
我想在日期选择器中禁用这些日期并更改颜色。这个怎么做?
我有一个列表,其中包含 20 个项目(动态而非固定)。我想将这些项目显示在每行 3 或 4 个项目的容器中。
目前我正在获取附加的输出。
Column(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: List.generate(itemList.length,
(index) {
return Wrap(
children: <Widget>[
Container(
//height:140,
child: SizedBox(
width: 100.0,
height: 50.0,
child: Card(
color: Colors.white,
semanticContainer: true,
clipBehavior:
Clip.antiAliasWithSaveLayer,
shape: RoundedRectangleBorder(
borderRadius:
BorderRadius.circular(10.0),
),
elevation: 5,
margin: EdgeInsets.all(10),
child: Center(
child: Text(
(itemList.length[index]
.toUpperCase()),
style: TextStyle(
color: Colors.blue,
fontWeight: FontWeight.bold,
fontSize: 15.0,
),
),
),
),
)),
],
);
}),
),
Run Code Online (Sandbox Code Playgroud) flutter ×3