Reputation: 891
I am trying to put a TextField and an IconButton for a date picker together and have decided to use a SizedBox to do that with. I want them to be side by side.
I have used a Container with a SizedBox and will add the TextField and IconButton as children. However, when I do this I get an error on "children:". What am I doing wrong?
Container(
alignment: Alignment.centerLeft,
child:
SizedBox(
height: 50.0,
width: 150,
children: <Widget>[ <<<<<<< This is where the error is
TextField(
keyboardType: TextInputType.text,
controller: contractDateController,
textAlign: TextAlign.center,
onChanged: (value) {
trxnProvider.changecontractDate(value); //, loggedInUid);
},
decoration:
kTextFieldDecoration.copyWith(
hintText: 'Contract Date', labelText: 'Contract Date'),
),
IconButton(onPressed: () {_selectDate(context);}, icon: Icon(Icons.calendar_today)),
],),
),
Upvotes: 1
Views: 2459
Reputation: 1319
SizedBox() does not have "children" it can only take a "child", and to put both widgets side by side you can make the child attr of SizedBox() a Row() and inside that row put the TextField and the IconButton
Container(
alignment: Alignment.centerLeft,
child: SizedBox(
height: 50.0,
width: 150,
child: Row(
children: [
TextField(
keyboardType: TextInputType.text,
controller: contractDateController,
textAlign: TextAlign.center,
onChanged: (value) {
trxnProvider.changecontractDate(value); //, loggedInUid);
},
decoration: kTextFieldDecoration.copyWith(
hintText: 'Contract Date', labelText: 'Contract Date'),
),
IconButton(
onPressed: () {
_selectDate(context);
},
icon: Icon(Icons.calendar_today)),
],
),
),
),
Upvotes: 2