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

不知道如何摆脱这个错误(通常由 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,
                          ),
                        ),
                      )
                    ]),
穆罕默德·阿萨德·阿尔沙德

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

扩展 Row、Column 或 Flex 的子级以便子级填充可用空间的小部件。

使用 Expanded 小部件可以使 Row、Column 或 Flex 的子项扩展以填充沿主轴的可用空间(例如,水平用于行或垂直用于列)。如果扩展了多个子项,则根据弹性系数在它们之间分配可用空间。

来源:扩展类

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章