flutter_keyboard_actions icon indicating copy to clipboard operation
flutter_keyboard_actions copied to clipboard

Null exception in _isAvailable whenever app moves to AppLifeCycleState paused

Open robban112 opened this issue 1 year ago • 2 comments

Hi,

We're getting null exception errors in _isAvailable function for Pixel Android phones for Widgets wrapped in KeyboardAction with enabled set to false.

The reason for this is that setConfig is never called in initState, leading to config being set to null. Then, whenever AppLifeCycleState switches, _isAvailable will be called which force unwraps config leading to the exception.

Thanks.

Related error in Sentry / Console:

[sentry.platformError] [error] Uncaught Platform Error [sentry.platformError] _TypeError (Null check operator used on a null value) [sentry.platformError] #0 KeyboardActionstate._isAvailable (package:keyboard_actions/keyboard_actions.dart:127:18) #1 KeyboardActionstate._focusChanged (package:keyboard_actions/keyboard_actions.dart:267:9) #2 KeyboardActionstate.didChangeAppLifecycleState (package:keyboard_actions/keyboard_actions.dart:457:9) #3 WidgetsBinding.handleAppLifecycleStateChanged (package:flutter/src/widgets/binding.dart:794:16) #4 List.forEach (dart:core-patch/growable_array.dart:416:8) #5 ServicesBinding._handleLifecycleMessage (package:flutter/src/services/binding.dart:263:15) #6 BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:223:49) #7 _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:567:35) #8 _invoke2 (dart:ui/hooks.dart:344:13) #9 _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:45:5) #10 _Channel.push (dart:ui/channel_buffers.dart:135:31) #11 ChannelBuffers.push (dart:ui/channel_buffers.dart:343:17) #12 PlatformDispatcher._dispatchPlatformMessage (dart:ui/platform_dispatcher.dart:722:22) #13 _dispatchPlatformMessage (dart:ui/hooks.dart:257:31)

robban112 avatar Apr 02 '24 10:04 robban112

same issue

minhtritc97 avatar Jun 25 '24 04:06 minhtritc97