From cc71e49c1ff37473be7b9667c375df17cc4dfcf9 Mon Sep 17 00:00:00 2001 From: Brian Quinlan Date: Mon, 6 Nov 2023 10:40:44 -0800 Subject: [PATCH] Update pkgs/cronet_http/example/lib/main.dart Co-authored-by: Nate Bosch --- pkgs/cronet_http/example/lib/main.dart | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/pkgs/cronet_http/example/lib/main.dart b/pkgs/cronet_http/example/lib/main.dart index ca3a5b036f..61f11a7b01 100644 --- a/pkgs/cronet_http/example/lib/main.dart +++ b/pkgs/cronet_http/example/lib/main.dart @@ -75,13 +75,12 @@ class _HomePageState extends State { } final books = await _findMatchingBooks(query); - if (query == _lastQuery) { - // Avoid the situation where a slow-running query finishes late and - // replaces newer search results. - setState(() { - _books = books; - }); - } + // Avoid the situation where a slow-running query finishes late and + // replaces newer search results. + if (query != _lastQuery) return; + setState(() { + _books = books; + }); } @override