i’ m trying to display notification who has random strings who are stored in a List, everything is working but the problem is when i press allow to display notifications, it only show the same string from the list is not updating as i want to show another string that previous one. Here is the code:
String? randomYou;
String? randomName;
Color? randomColor;
final double height = MediaQuery.of(context).size.height;
final double width = MediaQuery.of(context).size.width;
final random = new Random();
randomName = names[random.nextInt(names.length)];
randomYou = random1[random.nextInt(random1.length)];
onPressed: () {
showToast();
NotificationService()
.showNotification(1, 'Hello', randomName!);
},
I had tried with setState but it s not updating
2
Answers
You should regenerate the random string
Can you try to push a function that generates random string? Like:
and