From a0a405ec9fb5cdb11299c0f03fde049b67ddb460 Mon Sep 17 00:00:00 2001 From: yuyanjun Date: Fri, 8 Nov 2024 18:24:26 +0800 Subject: [PATCH] Fix the issue of too many Console logs caused by frequent access to hasSystemFeature --- lib/src/floating.dart | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/src/floating.dart b/lib/src/floating.dart index 07b1524..6369e24 100644 --- a/lib/src/floating.dart +++ b/lib/src/floating.dart @@ -31,6 +31,8 @@ class Floating { Timer? _timer; Stream? _stream; + bool? _isPipAvailable; + static final _singleton = Floating._internal(); /// Facilities Floating singleton access. @@ -46,8 +48,8 @@ class Floating { /// by admin or device manufacturer. Also, the device may /// have Android version that was released without this feature. Future get isPipAvailable async { - final bool? supportsPip = await _channel.invokeMethod('pipAvailable'); - return supportsPip ?? false; + _isPipAvailable ??= await _channel.invokeMethod('pipAvailable'); + return _isPipAvailable ?? false; } /// Checks current app PiP status.