Error: The lower bound of "sdk: '>=2.7.0 <3.0.0'" must be 2.12.0' or higher to enable null safety

13.8k views Asked by At

Help please. I get the error in the title when trying to run the app. My dart version is 3.0.3 and here is the content of the pubspec.yaml file:


version: 1.15.1+1

environment:
  sdk: ">=2.12.0"

dependencies:
  flutter:
    sdk: flutter
  flutter_bloc: ^7.3.1
  equatable:

  # Http
  dio: ^4.0.0
  pretty_dio_logger: ^1.1.1
  jwt_decoder: ^2.0.0

  # Database
  floor: ^1.4.1
  uuid: ^3.0.2
  localstorage: ^4.0.0+1


  # UI
  avatar_glow: ^2.0.1
  flutter_launcher_icons: ^0.9.0
  image_picker: ^0.8.0
  transparent_image: ^2.0.0
  flutter_svg: ^0.22.0
  lottie: ^1.1.0
  fluttertoast: ^8.0.9

  # Logger
  logger: ^0.7.0+2
  logger_flutter: ^0.7.1

  get: ^4.6.5
  permission_handler: ^8.0.0+2
  audioplayers: ^0.20.0
  rxdart: ^0.26.0
  ota_update: ^4.0.2
  package_info_plus: ^1.4.3
  cached_network_image: ^3.2.3



dev_dependencies:
  flutter_test:
    sdk: flutter
  bloc_test: ^8.0.0
  mockito: ^5.3.2
  floor_generator: ^1.2.0
  build_runner: ^2.1.11

flutter_icons:
  android: true
  ios: true
  image_path: "assets/png/icon_dit_jade.png"

flutter:

  uses-material-design: true

  assets:
    - assets/
    - assets/animated/
    - assets/png/

  fonts:
    - family: OpenSans
      fonts:
        - asset: assets/fonts/OpenSans-Light.ttf
        - asset: assets/fonts/OpenSans-SemiBold.ttf
          weight: 600
    - family: Ubuntu
      fonts:
        - asset: assets/fonts/Ubuntu-Regular.ttf
          style: normal
        - asset: assets/fonts/Ubuntu-Italic.ttf
          style: italic

I tried migrating using the commands: dart pub outdated --node=null-safety and dart pub update --node=null-safety but I get the error ERROR: "Because jadbot depends on logger_flutter >=0.7.0 which doesn't support null safety, version solving failed."

when trying to downgrade to dart version 2.19.0 I get the result of the attached screenshot error when trying to dongrade

used dart fix --dry-run and dart fix --apply and tried running the app after but got this error: Error after dart fixx apply

2

There are 2 answers

0
cresentlove222 On BEST ANSWER

Downgrading the version of dart worked for me. Anyone who has the same issue should try matching versions, as it seemed to be the probem.

1
Shady On

You should change your environment from

environment:
  sdk: ">=2.7.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

to

environment:
  sdk: '>=3.2.4 <4.0.0'

dependencies:
  flutter:
    sdk: flutter