Reputation: 4016
I'm relatively new to flutter but I've been play around flutter for a while.
What I wanted to create was a new card in a list when I press on a FAB. (ie. you press the FAB and it takes you to the insert text page, and then you press ENTER and then it will pull through your information into the card which is now added to the list).
I've been okay doing something similar with a ListView, but struggling to get this to work, although I thought the concept would be similar?
Upvotes: 0
Views: 212
Reputation: 5917
You should have the list of items in memory; then, when you render the cards, use the list; something like this:
@override
Widget build(BuildContext context) {
Widget[] children = cards.map((card) => new CardWidget(card)).toList();
return new Column(children: children);
}
When you click the FAB, just call setState
and add a new element to the list; your build method should be called again automatically (because of setState). So, somehting like this:
onTap: (evt) => setState(() => cards.add(new Card()))
Upvotes: 1