Serge Middendorf
 · FlutterFlow Guru and Moderator, Head of Dev @Middnight

GetRandom TYPE from a LIST

This litte action will grab a random element from a List of elements passed into it. The list can be any type. In my case its a List. So you can change the action to your liking^^It could be references too... I personally used it for a nerdy rpg app and it is used to throw a dice where the dice has strings on its sides.

 
CUSTOM ACTION
return String, SINGLE
parameters List ("attrList")

Require Pub Dev Dependency:
randomizer_null_safe: ^0.1.5Code Snippet:
import 'package:randomizer_null_safe/randomizer_null_safe.dart';

Future rollDiceResult(List attrList) async {
  
  Randomizer randomizer = Randomizer.instance();
  
  String result = randomizer.randomElementFromList(attrList);
        return result;

}  

2
5 replies