mirror of
https://github.com/twonlyapp/twonly-app.git
synced 2026-07-18 02:24:07 +00:00
fix performance issue
This commit is contained in:
parent
3cdbd69d88
commit
07037537e1
1 changed files with 13 additions and 2 deletions
|
|
@ -208,10 +208,16 @@ class EmojiFloatWidgetState extends State<EmojiFloatWidget>
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
_ticker = createTicker(_tick)..start();
|
_ticker = createTicker(_tick);
|
||||||
}
|
}
|
||||||
|
|
||||||
void _tick(Duration elapsed) {
|
void _tick(Duration elapsed) {
|
||||||
|
if (_particles.isEmpty) {
|
||||||
|
_ticker.stop();
|
||||||
|
_lastTick = Duration.zero;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
final dt = (_lastTick == Duration.zero)
|
final dt = (_lastTick == Duration.zero)
|
||||||
? 0.016
|
? 0.016
|
||||||
: (elapsed - _lastTick).inMicroseconds / 1e6;
|
: (elapsed - _lastTick).inMicroseconds / 1e6;
|
||||||
|
|
@ -258,7 +264,12 @@ class EmojiFloatWidgetState extends State<EmojiFloatWidget>
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
setState(() {});
|
if (!_ticker.isActive) {
|
||||||
|
_lastTick = Duration.zero;
|
||||||
|
_ticker.start();
|
||||||
|
} else {
|
||||||
|
if (mounted) setState(() {});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue