I have this code that will get a list of reminders in DB and show it on the screen. It works fine with the reminder list. The problem is when the list is empty (there is no reminder), i want it to show some text like "There is no reminder". So i tried with Column, Text widget, i wrapped them in a list like below but nothing shown on screen.
If i remove the [], it is error A value of type ‘Card’ can’t be returned from the method ‘buildReminderList’ because it has a return type of ‘List’.
Does anyone know how to make a text like "There is no reminder" show in the case when "Upcoming" list is empty.
List<Widget> buildReminderList(List<Reminder> reminders) {
debugPrint(reminders.length.toString());
if (reminders != null)
return reminders.map((Reminder reminder)
=> ListTile()).toList();
else
return [Card(
child: ListTile(
title: Text("There is no reminder", style: TextStyle(fontWeight: FontWeight.bold)),
)
)];
}
2
Answers
Simply replace
List<Widget>
withWidget
:-Result
try this way