marcglasberg / back_button_interceptor

Flutter Package: May be used to intercept the Android back-button, as an alternative to `WillPopScope`.
BSD 2-Clause "Simplified" License
105 stars 21 forks source link

version 5.1.0 compile fail #18

Closed MagicalWater closed 2 years ago

MagicalWater commented 2 years ago

console message

../../development/flutter/.pub-cache/hosted/pub.dartlang.org/back_button_interceptor-5.1.0/lib/src/back_button_interceptor.dart:30:31: Error: Property 'handlePopRoute' cannot be accessed on 'WidgetsBinding?' because it is potentially null.
     - 'WidgetsBinding' is from 'package:flutter/src/widgets/binding.dart' ('../../development/flutter/packages/flutter/lib/src/widgets/binding.dart').
    Try accessing using ?. instead.
          WidgetsBinding.instance.handlePopRoute;
                                  ^^^^^^^^^^^^^^

WidgetsBinding.instance is null safety

noga-dev commented 2 years ago

run flutter upgrade

FiShelly commented 2 years ago

may be use 6.x is better? some project do not want to update flutter version. @noga-dev

noga-dev commented 2 years ago

There's no reason not to upgrade. It's stable.

marcglasberg commented 2 years ago

@FiShelly I retracted version 5.1.0 and published another one as 6.0.0.

Try running pub get again, or else just fix the version to 5.0.2 and remove the ^ in your pubspec.yaml file.

  back_button_interceptor: 5.0.2
FiShelly commented 2 years ago

@FiShelly I retracted version 5.1.0 and published another one as 6.0.0.

Try running pub get again, or else just fix the version to 5.0.2 and remove the ^ in your pubspec.yaml file.

  back_button_interceptor: 5.0.2

all right, thx~