Dart 是否有一个函数返回一个介于最小值和最大值之间的整数?

Dart 是否有一个函数返回一个介于最小值和最大值之间的整数?,dart,Dart,我很确定有这样一个函数,我只是不知道如何正确地搜索它 在使用大量词语之前,我将通过一个示例向您展示我的意思: // the function should have the following input: getValueBetweenMinAndMax(int min, int max, int input); // and the following output: getValueBetweenMinAndMax(100, 200, 50) // should return 100 g

我很确定有这样一个函数,我只是不知道如何正确地搜索它

在使用大量词语之前,我将通过一个示例向您展示我的意思:

// the function should have the following input:
getValueBetweenMinAndMax(int min, int max, int input);

// and the following output:
getValueBetweenMinAndMax(100, 200, 50) // should return 100
getValueBetweenMinAndMax(100, 200, 150) // should return 150
getValueBetweenMinAndMax(100, 200, 250) // should return 200
我只是想确定,在我自己编写一个函数之前,没有这样的函数。
提前谢谢各位

这是一个包含两个if/then语句的简单函数。你只要自己写就行了。

我刚找到它。 我搜索的方法是.clamp(num lowerLimit,num upperLimit)


第三个参数(值)的作用是什么?这是干什么用的?我不确定我是否完全理解了这个问题这是输入。。我想输入一个整数,并希望确保返回值至少为min,最多为maxI。我想不起来有没有看到一个预先制作的功能。创建自己的实现需要帮助吗?我刚找到。您可以对num:)类型调用.clamp(int lowerLimit,int upperLimit)谢谢您的帮助!:)很好+我知道这一点,但我从其他语言知道它们有这样的功能。顺便说一句,我刚找到它。它是。钳制(num lowerLimit,num upperLimit)。但还是要谢谢你!:)