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,
),
),
)
]),
An InputDecorator, which is typically created by a TextField, cannot have an unbounded width.
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With