|
| 1 | +--- a/lib/src/widgets/emoji_picker/emoji_builder.dart |
| 2 | ++++ b/lib/src/widgets/emoji_picker/emoji_builder.dart |
| 3 | +@@ -1,7 +1,7 @@ |
| 4 | + import 'dart:convert'; |
| 5 | ++import 'dart:io'; |
| 6 | + |
| 7 | + import 'package:build/build.dart'; |
| 8 | +-import 'package:http/http.dart' as http; |
| 9 | + import 'package:interstellar/src/utils/trie.dart'; |
| 10 | + |
| 11 | + Builder emojiBuilder(BuilderOptions options) => |
| 12 | +@@ -29,15 +29,9 @@ |
| 13 | + }; |
| 14 | + |
| 15 | + Future<String> _generateContent() async { |
| 16 | +- final dataResponse = await http.get( |
| 17 | +- Uri.parse('$_sourcePrefix/compact.raw.json'), |
| 18 | +- ); |
| 19 | +- final dataJson = jsonDecode(dataResponse.body); |
| 20 | ++ final dataJson = jsonDecode(await File('@compact.raw.json@').readAsString()) as List; |
| 21 | + |
| 22 | +- final messagesResponse = await http.get( |
| 23 | +- Uri.parse('$_sourcePrefix/messages.raw.json'), |
| 24 | +- ); |
| 25 | +- final messagesJson = jsonDecode(messagesResponse.body); |
| 26 | ++ final messagesJson = jsonDecode(await File('@messages.raw.json@').readAsString()) as Map<String, dynamic>; |
| 27 | + |
| 28 | + final s = StringBuffer() |
| 29 | + ..write(''' |
| 30 | +@@ -53,8 +47,9 @@ |
| 31 | + |
| 32 | + final emojiGroups = <String>[]; |
| 33 | + |
| 34 | +- for (var i = 0; i < (messagesJson['groups'] as List).length; i++) { |
| 35 | +- final group = messagesJson['groups'][i]; |
| 36 | ++ final groups = messagesJson['groups'] as List; |
| 37 | ++ for (var i = 0; i < groups.length; i++) { |
| 38 | ++ final group = groups[i] as Map<String, dynamic>; |
| 39 | + |
| 40 | + assert(group['order'] == i, 'Emoji group order value should match index'); |
| 41 | + |
| 42 | +@@ -61,4 +56,4 @@ |
| 43 | +- emojiGroups.add(group['message']); |
| 44 | ++ emojiGroups.add(group['message'] as String); |
| 45 | + } |
| 46 | + |
| 47 | + s |
| 48 | +@@ -72,7 +67,8 @@ |
| 49 | + |
| 50 | + { |
| 51 | + var i = 0; |
| 52 | +- for (final emoji in dataJson) { |
| 53 | ++ for (final emojiItem in dataJson) { |
| 54 | ++ final emoji = emojiItem as Map<String, dynamic>; |
| 55 | + if (emoji['group'] == null || emoji['order'] == null) continue; |
| 56 | + |
| 57 | + assert(emoji['order'] == i + 1, 'Emoji order value should match index'); |
| 58 | +@@ -84,9 +80,9 @@ |
| 59 | + : emoji['emoticon']), |
| 60 | + ]; |
| 61 | + |
| 62 | +- trie.addChild(Trie.normalizeTerm(emoji['label']), {i}); |
| 63 | ++ trie.addChild(Trie.normalizeTerm(emoji['label'] as String), {i}); |
| 64 | + for (final tag in tags) { |
| 65 | +- trie.addChild(Trie.normalizeTerm(tag), {i}); |
| 66 | ++ trie.addChild(Trie.normalizeTerm(tag as String), {i}); |
| 67 | + } |
| 68 | + |
| 69 | + s |
| 70 | +@@ -93,9 +89,9 @@ |
| 71 | + ..write('const Emoji("') |
| 72 | +- ..write(emoji['unicode']) |
| 73 | ++ ..write(emoji['unicode'] as String) |
| 74 | + ..write('","') |
| 75 | +- ..write(emoji['label']) |
| 76 | ++ ..write(emoji['label'] as String) |
| 77 | + ..write('",') |
| 78 | +- ..write(emoji['group']) |
| 79 | ++ ..write(emoji['group'].toString()) |
| 80 | + ..write('),\n'); |
| 81 | + |
| 82 | + i++; |
0 commit comments