基于flutterflow-ui v0.3.1版本 去除google ad 与google map
This commit is contained in:
51
lib/src/utils/random_data.dart
Normal file
51
lib/src/utils/random_data.dart
Normal file
@@ -0,0 +1,51 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
final _random = Random();
|
||||
|
||||
int randomInteger(int min, int max) {
|
||||
return _random.nextInt(max - min + 1) + min;
|
||||
}
|
||||
|
||||
double randomDouble(double min, double max) {
|
||||
return _random.nextDouble() * (max - min) + min;
|
||||
}
|
||||
|
||||
String randomString(
|
||||
int minLength,
|
||||
int maxLength,
|
||||
bool lowercaseAz,
|
||||
bool uppercaseAz,
|
||||
bool digits,
|
||||
) {
|
||||
var chars = '';
|
||||
if (lowercaseAz) {
|
||||
chars += 'abcdefghijklmnopqrstuvwxyz';
|
||||
}
|
||||
if (uppercaseAz) {
|
||||
chars += 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
}
|
||||
if (digits) {
|
||||
chars += '0123456789';
|
||||
}
|
||||
return List.generate(randomInteger(minLength, maxLength),
|
||||
(index) => chars[_random.nextInt(chars.length)]).join();
|
||||
}
|
||||
|
||||
// Random date between 1970 and 2025.
|
||||
DateTime randomDate() {
|
||||
// Random max must be in range 0 < max <= 2^32.
|
||||
// So we have to generate the time in seconds and then convert to milliseconds.
|
||||
return DateTime.fromMillisecondsSinceEpoch(
|
||||
randomInteger(0, 1735689600) * 1000);
|
||||
}
|
||||
|
||||
String randomImageUrl(int width, int height) {
|
||||
return 'https://picsum.photos/seed/${_random.nextInt(1000)}/$width/$height';
|
||||
}
|
||||
|
||||
Color randomColor() {
|
||||
return Color.fromARGB(
|
||||
255, _random.nextInt(255), _random.nextInt(255), _random.nextInt(255));
|
||||
}
|
||||
Reference in New Issue
Block a user