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