2022-06-29 17:21:21 +00:00
|
|
|
import 'dart:convert';
|
2020-10-22 18:24:24 +00:00
|
|
|
import 'dart:math';
|
|
|
|
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
|
2020-10-24 18:50:12 +00:00
|
|
|
extension StringExtension on String {
|
|
|
|
String capitalized() {
|
|
|
|
return "${this[0].toUpperCase()}${this.substring(1)}";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-22 18:24:24 +00:00
|
|
|
Future<String> generateName() async {
|
|
|
|
final randomThing = Random();
|
|
|
|
final adjectiveStringRaw =
|
2020-10-24 18:50:12 +00:00
|
|
|
await rootBundle.loadString('assets/text/Wallet_Adjectives.txt');
|
2020-10-22 18:24:24 +00:00
|
|
|
final nounStringRaw =
|
2020-10-24 18:50:12 +00:00
|
|
|
await rootBundle.loadString('assets/text/Wallet_Nouns.txt');
|
2022-06-29 17:21:21 +00:00
|
|
|
|
|
|
|
final ls = LineSplitter();
|
|
|
|
final adjectives = ls.convert(adjectiveStringRaw);
|
|
|
|
final nouns = ls.convert(nounStringRaw);
|
|
|
|
|
2020-10-22 18:24:24 +00:00
|
|
|
final chosenAdjective = adjectives[randomThing.nextInt(adjectives.length)];
|
|
|
|
final chosenNoun = nouns[randomThing.nextInt(nouns.length)];
|
2020-10-24 18:50:12 +00:00
|
|
|
final returnString =
|
|
|
|
chosenAdjective.capitalized() + ' ' + chosenNoun.capitalized();
|
2020-10-22 18:24:24 +00:00
|
|
|
return returnString;
|
2020-10-24 18:50:12 +00:00
|
|
|
}
|