in my project I want to add the textinput from a Textfield into a List to build a Listview.builder. The Problem is that I dont know how to add the String to the List (I want to use the string like in a todo app to make serval dates). (for example) time.add(time1) isnt working and I hope someone can help me. Is there a completly other way to transport the Inputtext to the list, Im open for everything
First Page
class Homescreen extends StatefulWidget {
String time1;
String who1;
String where1;
String when1;
Homescreen({this.time1, this.who1, this.where1, this.when1});
@override
_HomescreenState createState() => _HomescreenState();
}
TextEditingController myControllertime = TextEditingController();
TextEditingController myControllerwho = TextEditingController();
TextEditingController myControllerwhen = TextEditingController();
TextEditingController myControllerwhere = TextEditingController();
class _HomescreenState extends State<Homescreen> {
List<String> time = ["8:00",];
List<String> who = ["Eric", ];
List<String> when = ["Friday 21.4.21",];
List<String> where = ["At McDonalds", ];
ListView.builder(
physics: NeverScrollableScrollPhysics(),
shrinkWrap: true,
itemCount: where.length,
itemBuilder: (BuildContext context, int Index) {
return Column(children: [
SizedBox(
height: 40,
),
Container(
child: GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Meet1()));
},
child: Container(
width: size.width * 0.9,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(
Radius.circular(70)),
gradient: LinearGradient(
begin: Alignment.topRight,
end: Alignment.bottomRight,
colors: [
Colors.orange,
Colors.purple,
],
),
),
child: Column(children: <Widget>[
SizedBox(
height: 10,
),
Padding(
padding: EdgeInsets.all(20),
child: Column(
children: <Widget>[
Text(
time[Index],
style: TextStyle(
color: Colors.white,
fontSize: 40,
fontWeight:
FontWeight.bold),
),
SizedBox(
height: 10,
),
Text(
who[Index],
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight:
FontWeight.bold),
),
Text(
when[Index],
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight:
FontWeight.bold),
),
Text(
where[Index],
style: TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight:
FontWeight.bold),
),
Second Page
TextButton(
child: Icon(
Icons.check_circle_outline_rounded,
color: Colors.green,
size: 120,
),
onPressed: () {
Navigator.pop(context, MaterialPageRoute(builder: (builder) {
return Homescreen(
time1: myControllertime.text,
who1: myControllerwho.text,
when1: myControllerwhen.text,
where1: myControllerwhere.text
,
);
}));
})
],
));
child: Column(children: <Widget>[
SizedBox(
height: 10,
),
Padding(
padding: EdgeInsets.all(25),
child: Column(
children: <Widget>[
TextField(
controller: myControllertime,
decoration: InputDecoration(hintText: " Time ")),
SizedBox(
height: 10,
),
TextField(
controller: myControllerwho,
decoration: InputDecoration(hintText: " Who "),
),
SizedBox(
height: 10,
),
TextField(
controller: myControllerwhen,
decoration: InputDecoration(hintText: " Date "),
),
SizedBox(
height: 10,
),
TextField(
controller: myControllerwhere,
decoration: InputDecoration(hintText: " Where "),
),