Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

An InputDecorator, which is typically created by a TextField, cannot have an unbounded width

Tags:

flutter

dart

Not sure how to get rid of this error (An InputDecorator, which is typically created by a TextField, cannot have an unbounded width.), but also make the two inner textfields take up the entire width of the column.

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,
                          ),
                        ),
                      )
                    ]),
like image 429
jdog Avatar asked Jun 05 '20 01:06

jdog


People also ask

Is typically created by a TextField Cannot have an unbounded width?

An InputDecorator, which is typically created by a TextField, cannot have an unbounded width.

How do you change the width on a TextField?

Changing TextField Width To change the TextField width, you can simply wrap your TextField inside the SizedBox widget and give the appropriate width value. Here's how you do it: Step 1: Wrap your TextField inside the SizedBox widget. Step 2: Inside the SizedBox, Add the width parameter and assign the appropriate value.

When a row is in a parent that does not provide a finite width constraint?

I/flutter ( 5480): When a row is in a parent that does not provide a finite width constraint, for example if it is in a I/flutter ( 5480): horizontal scrollable, it will try to shrink-wrap its children along the horizontal axis.

How do you use TextField in Flutter?

In Flutter, this can be done using TextEditingController . First, create a TextEditingController and set it as a controller property of your TextField widget. In this example, I have added an extra Button and Text widget which will show the added text when you click the “Show Text” button.


1 Answers

Keep your column, but wrap each of your text field in the Expanded widget. The reasoning is given from the official docs:

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.

Source: Expanded Class

like image 53
Mohammad Assad Arshad Avatar answered Sep 20 '22 06:09

Mohammad Assad Arshad