I am creating a form in flutter that will be used to capture data. One area of the capture form should be able to capture more than one entry. How can I use a button to add more fields so that it is possible for a user to enter more that one entry . This is the part of the form
_Details() {
return Column(
children: <Widget>[
Container(
alignment: Alignment.center,
width: double.infinity,
color: Theme.of(context).accentColor,
padding: const EdgeInsets.all(8.0),
child: Text("Details "),
),
SizedBox(
height: 5.0,
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
// crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisSize: MainAxisSize.min,
children: <Widget>[
TextFormField(
controller: _bankController,
decoration: InputDecoration(
hintText: 'Name',
),
),
SizedBox(
height: 5.0,
),
TextFormField(
controller: _bankController,
decoration: InputDecoration(
hintText: 'Branch',
),
)
],
),
),
],
);
}
first make a model class like this
then you just have to make a listview and call a widget function whereever you want, like this
now the last part you just have to add items in list For example you make a add button and in add's button onTap function you will write