fix(animation): WASM 모드 안정성 개선
- SchedulerBinding으로 프레임 빌드 중 setState 방지 - persistentCallbacks 단계에서 addPostFrameCallback으로 지연 처리
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
|
||||
import 'package:askiineverdie/src/core/animation/character_frames.dart';
|
||||
import 'package:askiineverdie/src/core/animation/race_character_frames.dart';
|
||||
@@ -48,7 +49,19 @@ class _RacePreviewState extends State<RacePreview> {
|
||||
|
||||
void _startAnimation() {
|
||||
_timer = Timer.periodic(const Duration(milliseconds: 400), (_) {
|
||||
if (mounted) {
|
||||
if (!mounted) return;
|
||||
|
||||
// 프레임 빌드 중이면 다음 프레임까지 대기 (WASM 모드 안정성)
|
||||
if (SchedulerBinding.instance.schedulerPhase ==
|
||||
SchedulerPhase.persistentCallbacks) {
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_currentFrame++;
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
_currentFrame++;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user