| 1 | import 'dart:convert'; |
| 2 | import 'dart:math'; |
| 3 | |
| 4 | import 'package:flutter/services.dart'; |
| 5 | |
| 6 | extension StringExtension on String { |
| 7 | String capitalized() => "${this[0].toUpperCase()}${this.substring(1)}"; |
| 8 | } |
| 9 | |
| 10 | Future<String> generateName() async { |
| 11 | final randomThing = Random(); |
| 12 | final adjectiveStringRaw = await rootBundle.loadString("assets/text/Wallet_Adjectives.txt"); |
| 13 | final nounStringRaw = await rootBundle.loadString("assets/text/Wallet_Nouns.txt"); |
| 14 | |
| 15 | final ls = LineSplitter(); |
| 16 | final adjectives = ls.convert(adjectiveStringRaw); |
| 17 | final nouns = ls.convert(nounStringRaw); |
| 18 | |
| 19 | final chosenAdjective = adjectives[randomThing.nextInt(adjectives.length)].capitalized(); |
| 20 | final chosenNoun = nouns[randomThing.nextInt(nouns.length)].capitalized(); |
| 21 | return "$chosenAdjective $chosenNoun"; |
| 22 | } |