【发布时间】:2020-01-09 09:19:06
【问题描述】:
我正在尝试从 PHP MySQL 获取布尔值。我想打印这个布尔值。我得到 2 个值 NULL 和 BOOL VALUE。 这是我的代码:
Future<String> getTabData() async {
final postData = {"token": uToken};
final sendResponse = await http.post(serverURL + "/addpage.php", body: postData);
if (sendResponse.statusCode == 200) {
Map<String, dynamic> userData = jsonDecode(sendResponse.body);
var resCode = await userData["res"];
return resCode;
} else {
throw Exception('Failed to load content');
}
} //_getTabData
String _rCode="";
@override
void initState() {
// TODO: implement initState
super.initState();
if (_rCode == "") {
getTabData().then((String rxCode) =>
setState(() {
_rCode = rxCode;
}));
}
}
@override
Widget build(BuildContext context) {
String rCode = _rCode;
print("RC: $rCode");
return SafeArea(
child: Scaffold(
body: Stack(
children: <Widget>[
Container(
width: MediaQuery
.of(context)
.size
.width,
height: MediaQuery
.of(context)
.size
.height,
decoration: BoxDecoration(
gradient: grdMainGradient,
),
child: Column(
children: <Widget>[
],
),
),
],
),
),
);
} //
【问题讨论】: