Я все еще новичок во Flutter. Здесь я хочу выбрать значение из выпадающего списка в поле формы категории. Но я получаю сообщение об ошибке при попытке определить
child: DropdownButtonHideUnderline
внутри Textformfield. Я пытаюсь найти решение, но не могу найти его и не могу запрограммировать его самостоятельно. Я надеюсь, что вы можете мне помочь. Есть ли другой способ архивировать это?
мои коды здесь, заранее спасибо за ваше руководство.
class Home extends StatefulWidget {
@override
_HomeState createState() => _HomeState();
}
class _HomeState extends State<Home> {
final AuthService _auth = AuthService();
final _formKey = GlobalKey<FormState>();
String error = '';
bool loading = false;
String name = '';
String nickname = '';
String city = '';
@override
Widget build(BuildContext context) {
return Container(
child: Scaffold(
backgroundColor: Colors.brown[50],
appBar: AppBar(
title: Text('Brew Crew'),
backgroundColor: Colors.brown[400],
elevation: 0.0,
actions: <Widget>[
FlatButton.icon(
icon: Icon(Icons.person),
label: Text('logout'),
onPressed: () async {
await _auth.signOut();
},
),
],
),
body: Container(
padding: EdgeInsets.symmetric(vertical: 20.0, horizontal: 50.0),
child: Form(
key: _formKey,
child: SingleChildScrollView(
child: Column(
children: <Widget>[
SizedBox(height: 20.0),
TextFormField(
decoration: textInputDecoration.copyWith(hintText: 'Name'),
validator: (val) => val.isEmpty ? 'Enter your name' : null,
onChanged: (val) {
setState(() => name = val);
},
),
SizedBox(height: 20.0),
TextFormField(
decoration: textInputDecoration.copyWith(hintText: 'NickName'),
onChanged: (val) {
setState(() => nickname = val);
},
),
SizedBox(height: 20.0),
TextFormField(
decoration: textInputDecoration.copyWith(hintText: 'City'),
validator: (val) => val.isEmpty ? 'Enter your city' : null,
onChanged: (val) {
setState(() => city = val);
},
),
SizedBox(height: 20.0),
TextFormField(
decoration: textInputDecoration.copyWith(hintText: 'Category'),
validator: (val) => val.isEmpty ? 'Please select a category' : null,
onChanged: (val) {
setState(() => nickname = val);
},
),
SizedBox(height: 20.0),
RaisedButton(
color: Colors.pink[400],
child: Text(
'Submit',
style: TextStyle(color: Colors.white),
),
onPressed: () async {
}
),
SizedBox(height: 12.0),
Text(
error,
style: TextStyle(color: Colors.red, fontSize: 14.0),
)
],
),
),
),
),
),
);
}
}