I was trying to make both the sideview menu and search bar (textfield) in row but textfield is giving too many positional errors and i tried all possible solutions on stackoverflow and github and still dont get it .
here:
{
return Padding(
padding: EdgeInsets.all(30),
child:Row(
TextField(
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'Search..',
prefixIcon: Align(
widthFactor: 1.0,
heightFactor: 1.0,
child: Icon( Icons.search,),),
),
),/
Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: <Widget>[
DrawerHeader(
child: Text(
'Side menu',
style: TextStyle(color: Colors.white, fontSize: 25),
),
decoration: BoxDecoration(
color: Colors.green,
image: DecorationImage(
fit: BoxFit.fill,
image: AssetImage('assets/images/cover.jpg'))),
),
ListTile(
leading: Icon(Icons.input),
title: Text('Welcome'),
onTap: () => {},
),
ListTile(
leading: Icon(Icons.verified_user),
title: Text('Profile'),
onTap: () => {Navigator.of(context).pop()},
),
ListTile(
leading: Icon(Icons.settings),
title: Text('Settings'),
onTap: () => {Navigator.of(context).pop()},
),
ListTile(
leading: Icon(Icons.border_color),
title: Text('Feedback'),
onTap: () => {Navigator.of(context).pop()},
),
ListTile(
leading: Icon(Icons.exit_to_app),
title: Text('Logout'),
onTap: () => {Navigator.of(context).pop()},
),
],
),
),
),
);
}
CodePudding user response:
It seems you put the textfield()
and drawer()
into Row()
widget incorrectly.
Here is a correct sample:
Row(children:[Textfield(),Drawer,],),
When adding values for Row()
and Column()
you will need to add it into the children
property.
CodePudding user response:
Try this,
}
return Padding(
padding: const EdgeInsets.all(30),
child: Row(
children: [
const TextField(
decoration: InputDecoration(
border: OutlineInputBorder(),
labelText: 'Search..',
prefixIcon: Align(
widthFactor: 1.0,
heightFactor: 1.0,
child: Icon(
Icons.search,
),
),
),
),
Drawer(
child: ListView(
padding: EdgeInsets.zero,
children: <Widget>[
const DrawerHeader(
child: Text(
'Side menu',
style: TextStyle(color: Colors.white, fontSize: 25),
),
decoration: BoxDecoration(
color: Colors.green,
image: DecorationImage(
fit: BoxFit.fill,
image: AssetImage('assets/images/cover.jpg'))),
),
ListTile(
leading: const Icon(Icons.input),
title: const Text('Welcome'),
onTap: () => {},
),
ListTile(
leading: const Icon(Icons.verified_user),
title: const Text('Profile'),
onTap: () => {Navigator.of(context).pop()},
),
ListTile(
leading: const Icon(Icons.settings),
title: const Text('Settings'),
onTap: () => {Navigator.of(context).pop()},
),
ListTile(
leading: const Icon(Icons.border_color),
title: const Text('Feedback'),
onTap: () => {Navigator.of(context).pop()},
),
ListTile(
leading: const Icon(Icons.exit_to_app),
title: const Text('Logout'),
onTap: () => {Navigator.of(context).pop()},
),
],
),
)
],
));
}