mobxjs / mobx.dart

MobX for the Dart language. Hassle-free, reactive state-management for your Dart and Flutter apps.
https://mobx.netlify.app
MIT License
2.39k stars 310 forks source link

Unable to Implemment on my project #701

Open marcojr opened 3 years ago

marcojr commented 3 years ago

I just create a blank project with intention to create a sample project to demo how mobx works. So, everything that I am using is the latest version and there is just mobx related libs installed. However I am receiving:

Because mobx_codegen >=2.0.3 depends on analyzer ^2.0.0 which depends on meta ^1.7.0, mobx_codegen >=2.0.3 requires meta ^1.7.0.

And because every version of flutter from sdk depends on meta 1.3.0, mobx_codegen >=2.0.3 is incompatible with flutter from sdk. So, because mobxflutter depends on both flutter any from sdk and mobx_codegen ^2.0.3, version solving failed. pub get failed (1; So, because mobxflutter depends on both flutter any from sdk and mobx_codegen ^2.0.3, version solving failed.) exit code 1

This is my pubspec:

name: mobxflutter
description: A new Flutter project.

# The following line prevents the package from being accidentally published to
# pub.dev using `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: ">=2.12.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  mobx: ^2.0.4
  flutter_mobx: ^2.0.2

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

dev_dependencies:
  #flutter_test:
  #  sdk: flutter

  mobx_codegen: ^2.0.3
  build_runner: ^2.1.1

# 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.
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:
  #   - 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: 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
MaikuB commented 3 years ago

@pavanpodila I believe this was caused by https://github.com/mobxjs/mobx.dart/pull/689. The current stable release (currently 2.2.3) of Flutter depends on a specific version of meta, which is 1.3.0. analyzer 2.x requires meta 1.7.0+. This means anyone currently on the stable channel cannot use the latest versions of MobX. From what I can see, the solutions for someone looking to use MobX are

  1. if you stay on stable channel, pin the version of mobx_codegen used. That is instead of specifying mobx_codegen: ^2.0.3 in the pubspec.yaml, specify mobx_codegen: 2.0.2.
  2. switch to another channel such as dev or master

Perhaps the aforementioned PR should be reverted so that mobx_codegen can republished to resolve the issue and then go into a 3.0.0 (pre)release. 2.0.2 is the last working version of mobx_codegen that works on the stable channel and one typically wouldn't expect that bumping the patch version would lead to a broken build, which can happen automatically due to use of the caret syntax. I noticed I wasn't able to build the code in mobx_examples due to this issue as well. Perhaps the build pipeline could also be updated so one of the checks it runs is build the code in mobx_examples as this would've helped catch the issue. The author of the PR also mentioned running into issues with doing this here

marcojr commented 3 years ago

I could manage to continue my work by adding:

dependency_overrides: meta: 1.7.0

on the pubspec. I will keep my temp workaround here just in case someone get stuck on it and need some help.

pavanpodila commented 3 years ago

Thanks @MaikuB for the analysis. I think your suggestion about pinning the mobx_codegen version to 2.0.2 is an acceptable solution for now. We will need to add more checks to our pipeline to catch this. Building the mobx_examples is a stop gate. Any ideas how we can do this on Github Actions ?

MaikuB commented 3 years ago

Afraid not as I haven't used GitHub actions at all as I'm using Cirrus CI for my other plugins at the moment. Adding this step would most likely cause it to fail on when trying to build on stable though due to the same issue reported in this thread