Watch
1
0
Fork
You've already forked nexus
0
forked from Nexus/nexus

Small refactor of emoji controller and widget

Isolated deserialization of the large emoji json to not keep main thread busy to long
Refactored textController logic in EmojiPickerButton to make popping mid buid impossible. The bug from the comment should be impossible now
(The bug could be reproduce with future.delayed and microtask but)
This commit is contained in:
istalri 2026-07-25 19:04:56 +02:00
commit 0813597a53
2 changed files with 43 additions and 25 deletions

View file

@ -1,6 +1,7 @@
import "dart:convert";
import "package:emoji_text_field/models/emoji_category.dart";
import "package:fast_immutable_collections/fast_immutable_collections.dart";
import "package:flutter/foundation.dart";
import "package:flutter/material.dart";
import "package:flutter_riverpod/flutter_riverpod.dart";
import "package:http/http.dart";
@ -19,9 +20,12 @@ class EmojiController extends AsyncNotifier<EmojiTuple> {
throw Exception("Failed to load emoji data");
}
final data = json.decode(response.body);
return compute(_parseEmojiJson, response.body);
}
final entries = (data as List)
static EmojiTuple _parseEmojiJson(String body) {
final data = json.decode(body) as List;
final entries = data
.cast<Map<String, dynamic>>()
.map(Emoji.fromJson)
.toIList();