Skip to content

Instantly share code, notes, and snippets.

@bannzai
Created November 23, 2022 11:32
Show Gist options
  • Save bannzai/1a99ea9e7d55c9953959162f3710bf19 to your computer and use it in GitHub Desktop.
Save bannzai/1a99ea9e7d55c9953959162f3710bf19 to your computer and use it in GitHub Desktop.
Dart#randomEmoji
import 'dart:math';
void main() async {
print(_randomEmoji());
}
String _randomEmoji() {
final emojis = _emojis();
return emojis[Random().nextInt(emojis.length - 1)];
}
List<String> _emojis() {
return _range().map((e) => String.fromCharCode(e)).toList();
}
Iterable<int> _range() sync* {
const start = 0x1F601;
const stop = 0x1F64F;
for (int value = start; value < stop; value += 1) {
yield value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment