【发布时间】:2020-10-25 06:24:49
【问题描述】:
如果待处理变成红色,我如何更改来自数据库的状态值的颜色,如果完成它变成绿色
我的数据库中有一个值等待和完成,如果显示的状态为等待状态,我的颤动中的状态颜色将为红色,如果完成,颜色将为绿色
final x = list[i];
debugPrint(x.toString());
return Container(
padding: EdgeInsets.all(20.0),
child: Row(
children: <Widget>[
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(
'Vessel Name:\t' + x["vesselname"],
style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.bold),
),
Text('Ship Call #:\t' + x["scn"], style: TextStyle(fontSize: 20.0)),
Text('Vessel Number:\t' + x["voyageno"], style: TextStyle(fontSize: 20.0)),
Text('Status:\t' + x["status"], style: TextStyle(fontSize: 20.0)),
Divider()
],
),
),
],
),
);
这是我对数据库的请求:
var url = "http://192.168.1.15/vessellog/read.php";
List<dynamic> list = [];
Future<void> getData() async {
list.clear();
setState(() {
loading = true;
});
Future<SharedPreferences> _prefs = SharedPreferences.getInstance();
SharedPreferences preferences = await _prefs;
String id = preferences.getString("id");
final response = await http.get(url + "?client_signature=$id");
debugPrint(response.body);
if (response.contentLength == 2) {
} else
setState(() {
list = jsonDecode(response.body);
loading = false;
});
}
【问题讨论】:
标签: flutter