diegoveloper/flutter_keyboard_actions

Multiple WidgetsBinding.instance compile errors

MatrixDev opened this issue · 1 comments

I have multiple compile errors after adding KeyboardActions:

../../Library/Flutter/.pub-cache/hosted/pub.dartlang.org/keyboard_actions-4.0.0/lib/keyboard_actions.dart:283:33: Error: Method 'addPostFrameCallback' cannot be called on 'WidgetsBinding?' because it is potentially null.
 - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../Library/Flutter/packages/flutter/lib/src/widgets/binding.dart').
Try calling using ?. instead.
        WidgetsBinding.instance.addPostFrameCallback((_) {
                                ^^^^^^^^^^^^^^^^^^^^
../../Library/Flutter/.pub-cache/hosted/pub.dartlang.org/keyboard_actions-4.0.0/lib/keyboard_actions.dart:293:45: Error: Property 'window' cannot be accessed on 'WidgetsBinding?' because it is potentially null.
 - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../Library/Flutter/packages/flutter/lib/src/widgets/binding.dart').
Try accessing using ?. instead.
      final value = WidgetsBinding.instance.window.viewInsets.bottom;
                                            ^^^^^^
../../Library/Flutter/.pub-cache/hosted/pub.dartlang.org/keyboard_actions-4.0.0/lib/keyboard_actions.dart:307:29: Error: Method 'addPostFrameCallback' cannot be called on 'WidgetsBinding?' because it is potentially null.
 - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../Library/Flutter/packages/flutter/lib/src/widgets/binding.dart').
Try calling using ?. instead.
    WidgetsBinding.instance.addPostFrameCallback((_) {
                            ^^^^^^^^^^^^^^^^^^^^
../../Library/Flutter/.pub-cache/hosted/pub.dartlang.org/keyboard_actions-4.0.0/lib/keyboard_actions.dart:425:37: Error: Property 'window' cannot be accessed on 'WidgetsBinding?' because it is potentially null.
 - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../Library/Flutter/packages/flutter/lib/src/widgets/binding.dart').
Try accessing using ?. instead.
            WidgetsBinding.instance.window.viewInsets,
                                    ^^^^^^
../../Library/Flutter/.pub-cache/hosted/pub.dartlang.org/keyboard_actions-4.0.0/lib/keyboard_actions.dart:426:37: Error: Property 'window' cannot be accessed on 'WidgetsBinding?' because it is potentially null.
 - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../Library/Flutter/packages/flutter/lib/src/widgets/binding.dart').
Try accessing using ?. instead.
            WidgetsBinding.instance.window.devicePixelRatio)
                                    ^^^^^^
../../Library/Flutter/.pub-cache/hosted/pub.dartlang.org/keyboard_actions-4.0.0/lib/keyboard_actions.dart:481:29: Error: Method 'removeObserver' cannot be called on 'WidgetsBinding?' because it is potentially null.
 - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../Library/Flutter/packages/flutter/lib/src/widgets/binding.dart').
Try calling using ?. instead.
    WidgetsBinding.instance.removeObserver(this);
                            ^^^^^^^^^^^^^^
../../Library/Flutter/.pub-cache/hosted/pub.dartlang.org/keyboard_actions-4.0.0/lib/keyboard_actions.dart:487:29: Error: Method 'addObserver' cannot be called on 'WidgetsBinding?' because it is potentially null.
 - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../Library/Flutter/packages/flutter/lib/src/widgets/binding.dart').
Try calling using ?. instead.
    WidgetsBinding.instance.addObserver(this);
                            ^^^^^^^^^^^
../../Library/Flutter/.pub-cache/hosted/pub.dartlang.org/keyboard_actions-4.0.0/lib/keyboard_actions.dart:490:31: Error: Method 'addPostFrameCallback' cannot be called on 'WidgetsBinding?' because it is potentially null.
 - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../Library/Flutter/packages/flutter/lib/src/widgets/binding.dart').
Try calling using ?. instead.
      WidgetsBinding.instance.addPostFrameCallback((_) {
                              ^^^^^^^^^^^^^^^^^^^^
../../Library/Flutter/.pub-cache/hosted/pub.dartlang.org/keyboard_actions-4.0.0/lib/external/keyboard_avoider/bottom_area_avoider.dart:85:31: Error: Method 'addPostFrameCallback' cannot be called on 'WidgetsBinding?' because it is potentially null.
 - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../Library/Flutter/packages/flutter/lib/src/widgets/binding.dart').
Try calling using ?. instead.
      WidgetsBinding.instance.addPostFrameCallback((_) {
                              ^^^^^^^^^^^^^^^^^^^^
../../Library/Flutter/.pub-cache/hosted/pub.dartlang.org/keyboard_actions-4.0.0/lib/external/keyboard_avoider/bottom_area_avoider.dart:151:29: Error: Method 'addPostFrameCallback' cannot be called on 'WidgetsBinding?' because it is potentially null.
 - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../Library/Flutter/packages/flutter/lib/src/widgets/binding.dart').
Try calling using ?. instead.
    WidgetsBinding.instance.addPostFrameCallback((_) {
                            ^^^^^^^^^^^^^^^^^^^^

WidgetsBinding.instance is nullable and all methods on it must be called with ?.