mirror of
https://github.com/foss42/apidash.git
synced 2025-06-17 11:54:51 +08:00
string utils
This commit is contained in:
19
packages/apidash_core/lib/utils/string_utils.dart
Normal file
19
packages/apidash_core/lib/utils/string_utils.dart
Normal file
@ -0,0 +1,19 @@
|
||||
import 'dart:math';
|
||||
|
||||
class RandomStringGenerator {
|
||||
static const _chars =
|
||||
'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890';
|
||||
static Random rnd = Random();
|
||||
|
||||
static String getRandomString(int length) =>
|
||||
String.fromCharCodes(Iterable.generate(
|
||||
length, (_) => _chars.codeUnitAt(rnd.nextInt(_chars.length))));
|
||||
|
||||
static String getRandomStringLines(int lines, int length) {
|
||||
List<String> result = [];
|
||||
for (var i = 0; i < lines; i++) {
|
||||
result.add(getRandomString(length));
|
||||
}
|
||||
return result.join('\n');
|
||||
}
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
export 'http_request_utils.dart';
|
||||
export 'http_response_utils.dart';
|
||||
export 'string_utils.dart';
|
||||
export 'uri_utils.dart';
|
||||
|
Reference in New Issue
Block a user