gpt4 book ai didi

flutter - 通常由 TextField 创建的 InputDecorator 不能具有无限宽度

转载 作者:行者123 更新时间:2023-12-03 04:21:42 25 4
gpt4 key购买 nike

不知道如何摆脱这个错误(通常由 TextField 创建的 InputDecorator 不能具有无限的宽度。),但也使两个内部文本字段占据了整个列的宽度。

Column(mainAxisSize: MainAxisSize.min, children: [
Container(
margin: const EdgeInsets.only(left: 50, right: 50),
child: AutoCompleteTextView(
suggestionsApiFetchDelay: 300,
focusGained: () {},
onTapCallback: (_) async {

},
focusLost: () {

},
onValueChanged: (String text) {

},
controller: startEditingController,
suggestionStyle:
Theme.of(context).textTheme.bodyText2,
getSuggestionsMethod: getLocationSuggestionsList,
tfTextAlign: TextAlign.left,
tfStyle: TextStyle(
fontSize: 16,
color: Theme.of(context).textTheme.bodyText2.color,
),
tfTextDecoration: InputDecoration(
contentPadding: EdgeInsets.only(top: 0, left: 8.0),
filled: true,
fillColor: Colors.white,
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.grey[800], width: 1.0),
borderRadius: BorderRadius.zero,
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.deepPurple[600], width: 1.0),
borderRadius: BorderRadius.zero,
),
hintText: "Current Location",
labelText: 'Start',
labelStyle: kcarPurpleLabelStyle,
),
),
),
Container(
margin:
const EdgeInsets.only(top: 5, left: 50, right: 50),
child: AutoCompleteTextView(
suggestionsApiFetchDelay: 300,
focusGained: () {},
onTapCallback: (_) async {

},
focusLost: () {

},
onValueChanged: (String text) {

},
controller: startEditingController,
suggestionStyle:
Theme.of(context).textTheme.bodyText2,
getSuggestionsMethod: getLocationSuggestionsList,
tfTextAlign: TextAlign.left,
tfStyle: TextStyle(
fontSize: 16,
color: Theme.of(context).textTheme.bodyText2.color,
),
tfTextDecoration: InputDecoration(
contentPadding: EdgeInsets.only(top: 0, left: 8.0),
filled: true,
fillColor: Colors.white,
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.grey[800], width: 1.0),
borderRadius: BorderRadius.zero,
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.deepPurple[600], width: 1.0),
borderRadius: BorderRadius.zero,
),
hintText: "Current Location",
labelText: 'Destination',
labelStyle: kcarPurpleLabelStyle,
),
),
)
]),

最佳答案

保留您的列,但将每个文本字段包装在 中扩展 小部件。推理来自官方文档:

A widget that expands a child of a Row, Column, or Flex so that the child fills the available space.

Using an Expanded widget makes a child of a Row, Column, or Flex expand to fill the available space along the main axis (e.g., horizontally for a Row or vertically for a Column). If multiple children are expanded, the available space is divided among them according to the flex factor.



来源: Expanded Class

关于flutter - 通常由 TextField 创建的 InputDecorator 不能具有无限宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62206654/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com