android - 如何在 flutter 中扩展一个 textField 看起来像一个文本区域

标签 android dart flutter textfield

当我在 landScape 模式下点击 textField 时,我想像 whatsapp 一样全屏展开

enter image description here

            TextFormField(
              keyboardType: TextInputType.number,
              decoration: InputDecoration(
                  prefixIcon: Padding(
                    padding: EdgeInsets.all(0.0),
                    child: Icon(Icons.person,
                        size: 40.0, color: Colors.white),
                  ),
                  hintText: "Input your opinion",
                  hintStyle: TextStyle(color: Colors.white30),
                  border: OutlineInputBorder(
                      borderRadius:
                      BorderRadius.all(new Radius.circular(25.0))),
                  labelStyle: TextStyle(color: Colors.white)),
              textAlign: TextAlign.center,
              style: TextStyle(
                color: Colors.white,
                fontSize: 25.0,
              ),
              controller: host,
              validator: (value) {
                if (value.isEmpty) {
                  return "Empty value";
                }
              },
            )

最佳答案

您需要做的就是在创建 TextField 时设置 maxLines 变量。 我在 Card 小部件中添加了文本字段,因此您可以看到总面积。

@override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Simple Material App"),
      ),
      body: Column(
        children: <Widget>[
          Card(
            color: Colors.grey,
            child: Padding(
              padding: EdgeInsets.all(8.0),
              child: TextField(
                maxLines: 8, //or null 
                decoration: InputDecoration.collapsed(hintText: "Enter your text here"),
              ),
            )
          )
        ],
      )
    );
  }

关于android - 如何在 flutter 中扩展一个 textField 看起来像一个文本区域,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54972928/

相关文章:

dart - Async Futures 按顺序运行直到完成

dart - 从 PopupMenuItem(溢出菜单)中删除填充

flutter - 将容器缩小到较小的 child 而不是扩大到填充 parent

android - FilePicker 在 Android 13 (Pixel 7) 上缺少权限

java - Android 项目(4.4.2)在 eclipse 和 adt 更新后未运行

dart - Dart-使用Map <String,String>的嵌套类

android - Flutter:适用于 Windows 的 iOS 模拟器

android - 如何使用 roboelectric 或 mockito 测试处理程序消息

android - View.setTag - 需要多个键 : resourceIDs

flutter - 创建一个带有圆形边框的按钮