diff --git a/pkgs/cupertino_http/lib/src/cupertino_api.dart b/pkgs/cupertino_http/lib/src/cupertino_api.dart index 8e870fa6e5..f072ce0d04 100644 --- a/pkgs/cupertino_http/lib/src/cupertino_api.dart +++ b/pkgs/cupertino_http/lib/src/cupertino_api.dart @@ -842,11 +842,11 @@ class URLSession extends _ObjectHolder { static void _decrementTaskCount() { assert(_taskCount > 0); + assert(_port != null); --_taskCount; - if (_taskCount == 0 && _port != null) { + if (_taskCount == 0) { _port?.close(); _port = null; - _taskCount = 0; } }