Hey everyone. I am trying to generate a random number from an Action Output Variable. But whenever I run the app it does not work. I know the Action Variable works. I'm not seeing any errors. But I also can't run the app in Test Mode only Run mode. I'm very new to Flutterflow. Coming from Godot. So please talk to me like I'm stupid lol. Thanks in advance for the support!!
Generate a Random Number from an Action Output Variable
Custom Code
This is the code I'm using for the custom Action. Here is a picture of the Action being used.
// Automatic FlutterFlow imports
import '/backend/backend.dart';
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
import '/custom_code/actions/index.dart'; // Imports other custom actions
import '/flutter_flow/custom_functions.dart'; // Imports custom functions
import 'package:flutter/material.dart';
// Begin custom action code
// DO NOT REMOVE OR MODIFY THE CODE ABOVE!
import 'dart:math';
Future<int> generateRandomInt(
BuildContext context,
int maxNumber,
) async {
// Add your function code here!
final random = Random();
// Generates a random integer between 1 and maxNumber - 1
return 1 + random.nextInt(maxNumber - 1);
Yes
2
16 replies