From 20818b6c498a82450a4de764e7ea1fe12f15cac0 Mon Sep 17 00:00:00 2001 From: Erick Date: Thu, 4 Jan 2024 10:13:50 -0300 Subject: [PATCH] fix: NesRunningTextLines --- lib/src/widgets/nes_running_text_lines.dart | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/src/widgets/nes_running_text_lines.dart b/lib/src/widgets/nes_running_text_lines.dart index f92e4e3..5e46ba3 100644 --- a/lib/src/widgets/nes_running_text_lines.dart +++ b/lib/src/widgets/nes_running_text_lines.dart @@ -52,6 +52,20 @@ class _NesRunningTextLinesState extends State { } } + bool _isArrayEqual(List a, List b) { + if (a.length != b.length) { + return false; + } + + for (var i = 0; i < a.length; i++) { + if (a[i] != b[i]) { + return false; + } + } + + return true; + } + @override void didUpdateWidget(NesRunningTextLines oldWidget) { super.didUpdateWidget(oldWidget); @@ -62,7 +76,7 @@ class _NesRunningTextLinesState extends State { } } - if (widget.texts != oldWidget.texts) { + if (!_isArrayEqual(widget.texts, oldWidget.texts)) { _initLines(); if (widget.running) { _start();