1

Getting this error while attempting to run my flutter app: (https://i.stack.imgur.com/9LKyH.png)

Flutter doctor is healthy: flutter doctor -v

All dependencies are on flutter pub get --major-versions

Here's my pubspec.yaml:

name: flutter project
description: A new Flutter project.

# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1

environment:
  sdk: ">=3.0.0 <4.0.0"

# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
  flutter:
    sdk: flutter
  auto_route: ^7.8.0
  copy_with_extension: ^5.0.3
  easy_sidemenu: ^0.5.0
  equatable: ^2.0.5
  feather_icons: ^1.2.0
  flutter_bloc: ^8.1.3

  #API calling
  http: ^1.1.0
  http_interceptor: ^2.0.0-beta.7
  responsive_grid: ^2.3.0

  #Local storage
  shared_preferences: ^2.2.0

  #Image view
  flutter_svg: ^2.0.7
  cached_network_image: ^3.2.3
  shimmer: ^3.0.0

  rxdart: ^0.27.7

  # Responsive UI :
  responsive_sizer: ^3.1.1
  font_awesome_flutter: ^10.4.0
  dropdown_button2: ^2.1.3
  number_pagination: ^0.0.3+2
  responsive_table: ^0.2.0+2
  analog_clock_picker: ^0.0.6

  #Auto complete textField tags
  textfield_tags: ^2.0.2

  #Charts
  syncfusion_flutter_charts: ^22.2.8

  #Toast messages
  bot_toast: ^4.0.4

  #Pick images for web:
  image_picker_web: ^3.0.0+1

  #Date format
  intl: ^0.18.1

  #Scan QR Codes
  qr_bar_code_scanner_dialog: ^0.0.5


  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2
  auto_route_generator: ^7.3.1

dev_dependencies:
  build_runner: ^2.1.8
  copy_with_extension_gen: ^5.0.2
  flutter_test:
    sdk: flutter

  # The "flutter_lints" package below contains a set of recommended lints to
  # encourage good coding practices. The lint set provided by the package is
  # activated in the `analysis_options.yaml` file located at the root of your
  # package. See that file for information about deactivating specific lint
  # rules and activating additional ones.
  flutter_lints: ^2.0.0

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

# The following section is specific to Flutter packages.
flutter:

  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true

  # To add assets to your application, add an assets section, like this:
  assets:
    - assets/images/
    - assets/icons/
  #   - images/a_dot_burr.jpeg
  #   - images/a_dot_ham.jpeg

  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/assets-and-images/#resolution-aware

  # For details regarding adding assets from package dependencies, see
  # https://flutter.dev/assets-and-images/#from-packages

  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  fonts:
    - family: Futura
      fonts:
        - asset: assets/fonts/futura_light_bt.ttf
          weight: 400
        - asset: assets/fonts/futura medium bt.ttf
          weight: 500
        - asset: assets/fonts/Futura Bold font.ttf
          weight: 700
  # fonts:
  #   - family: Schyler
  #     fonts:
  #       - asset: fonts/Schyler-Regular.ttf
  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/custom-fonts/#from-packages

I've tried adding both of these packages: https://pub.dev/packages/router_generator/install https://pub.dev/packages/auto_route_generator/install

This gives an error saying that I can't run with sound null safety, because the dependencies don't support null safety. To solve, tried adding to pubspec.yaml:

analyzer:
  enable-experiment:
  - non-nullable

When re-running, I get this error:

flutter run --no-sound-null-safety
Could not find an option named "no-sound-null-safety".
Run 'flutter -h' (or 'flutter <command> -h') for available flutter commands and options.

The only solution I've found: https://www.devopsschool.com/blog/flutter-cannot-run-with-sound-null-safety-because-the-following-dependencies-dont-support-null-safety/

Is to add

// @dart=2.9

To top of main.dart. Doing so gives me this error: error

Here's what happens when I run

flutter pub run build_runner build --delete-conflicting-outputs

flutter pub run build_runner build --delete conflicting-outputs Any suggestions?

Justin
  • 11
  • 2
  • It may help if you post your entire pubspec.yaml file. The top error you displayed is in "generated" code. Have you made sure all your generated code is up to date by running: flutter pub run build_runner build --delete-conflicting-outputs – John Weidner Aug 15 '23 at 04:45
  • Thanks @JohnWeidner . Included the entire pubspec.yaml and the output from running flutter pub run build_runner build --delete-conflicting-outputs (which errors out). Appreciate hearing your thoughts from there. – Justin Aug 15 '23 at 16:01
  • Upgrading a large project from non null safe to a null safe version can take some time. Just work one issue at a time and try to understand what and why you have to make a change. – John Weidner Aug 15 '23 at 23:07

0 Answers0