Flutter DropdownButton在选择选项时显示标签

问题描述 投票:2回答:1

可以Dropdown Button

 return DropdownButton<String>(
          items: <String>['Foo', 'Bar'].map((String value) {
            return new DropdownMenuItem<String>(
              value: value,
              child: new Text(value),
            );
          }).toList(),
          onChanged: (_) {},
        );

TextFormField中的装饰用户类似:

      TextFormField(
        controller: _titleController,
        decoration: InputDecoration(labelText: 'Input'),
        validator: (String value) {
          if (value != null && value.isEmpty) {
            return 'Please enter some text';
          }
        },
        style: Theme.of(context).textTheme.title,
      ),

[当在上面的TextFormField中写入某些内容时,将显示单词Input。像这样:

enter image description here

flutter
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.