我正在尝试在 flutter 中构建一个动态 TextField 列表,但不明白我如何处理它。
我的清单如下:
我的代码结构是:
ListView.builder(
shrinkWrap: true,
itemCount: itemList.length,
itemBuilder: (context, index) {
if(itemList.length == null) {
return _buildProgressIndicator();
} else {
return singleItemList(index);
}
})
Widget singleItemList(int index) {
if((itemList.length -1) < index)
{
return Container(child: null);
} else {
dynamic singleItem = itemList[index];
String counter = (index+1).toString();
return
Container(
decoration: BoxDecoration(
color: Colors.white,
),
child: Row(
children:[
Expanded(
flex: 1,
child: Text(counter,style: orderBookItemListCounter(),)
),
Expanded(
flex: 3,
child: TextField(
controller: _addProductToCart(counter),
decoration: InputDecoration(
labelText: "Qty", …Run Code Online (Sandbox Code Playgroud) 我的文本小部件看起来像Text("Last Active: some location area..").
我可以使用样式更改完整文本的文本样式。但我只是喜欢将 Last active 更改为粗体。Text("<b>Last Active</b> some location area name..")
如果我将 Row 用于单独的文本,它将起作用,但会出现间距问题。
什么是最好的解决方案。并使其大胆是唯一的要求。
谢谢
我只是随波逐流.我已经成功安装了它.
但是当我尝试运行它失败了.
以下是颤振医生-v的输出
PS C:\android-app\flutter-app\flutter_first_app> flutter doctor -v
Run Code Online (Sandbox Code Playgroud)
[?] Flutter (Channel master, v0.5.5-pre.9, on Microsoft Windows [Version 10.0.16299.461], locale en-US)
• Flutter version 0.5.5-pre.9 at C:\android-app\flutter
• Framework revision 587569337e (7 hours ago), 2018-06-13 00:02:21 +0200
• Engine revision a328531402
• Dart version 2.0.0-dev.60.0.flutter-a5e41681e5
[!] Android toolchain - develop for Android devices (Android SDK 28.0.0)
• Android SDK at C:\Users\Sreyah Admin\AppData\Local\Android\Sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.0
• ANDROID_HOME …Run Code Online (Sandbox Code Playgroud) 我正在使用 http 客户端进行 flutter 网络调用。
方法体:
static Future<http.Response> httpPost(
Map postParam, String serviceURL) async {
Map tempParam = {"id": "username", "pwd": "password"};
var param = json.encode(tempParam);
serviceURL = "http:xxxx/Login/Login";
// temp check
Map<String, String> headers = {
'Content-Type': 'application/json',
'cache-control': 'no-cache',
};
await http.post(serviceURL, headers: headers, body: param).then((response) {
return response;
});
}
Run Code Online (Sandbox Code Playgroud)
此外,相同的代码会返回对其他请求和 URL 的正确响应。首先,我尝试使用 chopper 客户端,但遇到了同样的问题。
我无法从服务器端检测到该问题。
任何帮助/提示都会有帮助
这里有一个有趣的问题:
简单的代码块if-else bock.在其他地方阻止if-else阶梯.虽然我写了一个真实的,但如果Color _orderStatus = Colors.blue;这仍然不起作用.
2.如果我们打印,orderItem['order_status'].toString() == "DELIVERED"这是显示的.
if((orderList.length -1) < index)
{
return Container(child: null);
} else {
dynamic orderItem = orderList[index];
Color _orderStatus = Colors.yellow;
if(true)
{
Color _orderStatus = Colors.blue;
} else if(orderItem['order_status'].toString() == "DELIVERED") {
Color _orderStatus = Colors.green;
} else if(orderItem['order_status'].toString() == "DISPATCHED") {
Color _orderStatus = Colors.purple;
} else if(orderItem['order_status'].toString() == "CANCEL") {
Color _orderStatus = Colors.red;
}
return Container(
Run Code Online (Sandbox Code Playgroud)