Dropsource / monarch

Monarch is a tool for building Flutter widgets in isolation. It makes it easy to build, test and debug complex UIs.
https://monarchapp.io
MIT License
428 stars 21 forks source link

Monarch broken on Flutter 3.22 #143

Closed philipmjohnson closed 1 month ago

philipmjohnson commented 1 month ago

We have integration testing in our app, and after a recent upgrade to Flutter 3.22 have found that we can now longer build the system using GitHub actions due to a dependency constraint conflict between Monarch and integration_test.

Here's the failure message from GitHub actions:

Note: vm_service is pinned to version 14.2.1 by integration_test from the flutter SDK.
See https://dart.dev/go/sdk-version-pinning for details.
Because no versions of monarch match >3.8.0 <4.0.0 and monarch 3.8.0 depends on vm_service >=9.4.0 <14.0.0, monarch ^3.8.0 requires vm_service >=9.4.0 <14.0.0.
And because every version of integration_test from sdk depends on vm_service 14.2.1, monarch ^3.8.0 is incompatible with integration_test from sdk.
So, because ggc_app depends on both integration_test from sdk and monarch ^3.8.0, version solving failed.

Flutter doctor:

flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.19.5, on macOS 14.4.1 23E224 darwin-arm64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.3)
[✓] IntelliJ IDEA Ultimate Edition (version 2024.1.1)
[✓] Connected device (3 available)
[✓] Network resources

• No issues found!

Advice on how to fix this? Thanks!

philipmjohnson commented 1 month ago

Once I update to Flutter 3.22.0, I get the same problem locally as the CI task:

Cocoapods 1.15.2
Dart SDK version: 3.4.0 
Flutter 3.22.0 
MacOS 14.4.1
Monarch version 2.2.3
ruby 3.0.3p157 
Xcode 15.3
philipmjohnson commented 1 month ago

Oh, and here's my pubspec.yml:

name: ggc_app
description: Geo Garden Club app
publish_to: 'none'
version: 1.28.0
environment:
  sdk: '>=3.2.0 <4.0.0'
dependencies:
  cached_network_image: ^3.3.0
  cloud_firestore: ^4.13.2
  collection: ^1.18.0
  # firebase_ui_auth has undeclared dependency on cupertino_icons
  cupertino_icons: ^1.0.6
  device_info_plus: ^10.1.0
  email_validator: ^2.1.17
  firebase_auth: ^4.14.1
  firebase_core: ^2.23.0
  firebase_crashlytics: ^3.4.8
  firebase_storage: ^11.5.2
  firebase_ui_auth: ^1.10.0
  flex_color_scheme: ^7.3.1
  flutter:
    sdk: flutter
  flutter_web_plugins:
    sdk: flutter
  flutter_chat_types: ^3.6.2
  flutter_chat_ui: ^1.6.10
  flutter_firebase_chat_core: ^1.6.7
  flutter_form_builder: ^9.1.1
  flutter_markdown: ^0.7.1
  flutter_native_splash: ^2.3.6
  flutter_riverpod: ^2.4.8
  form_builder_image_picker: ^4.0.0
  form_builder_validators: ^9.1.0
  freezed_annotation: ^2.4.1
  go_router: ^14.1.0
  http: ^1.1.0
  image_cropper: ^6.0.0
  image_picker: ^0.8.9
  intl: ^0.18.1
  jiffy: ^6.2.1
  json_annotation: ^4.8.1
  loading_indicator: ^3.1.1
  logger: ^2.0.2+1
  mime: ^1.0.4
  monarch_annotations: ^1.0.4
  multiselect_formfield: ^0.1.7
  open_filex: ^4.3.4
  path_provider: ^2.1.1
  riverpod_annotation: ^2.3.2
  timeago: ^3.6.1
  tuple: ^2.0.2
  uuid: ^4.2.1

dev_dependencies:
  analyzer: ^6.2.0
  build_runner: ^2.4.6
  custom_lint: ^0.6.4
  flutter_gen: ^5.3.2
  # flutter_launcher_icons 0.13.1 does not support background_color_ios.
  flutter_launcher_icons:
    git: https://github.com/fluttercommunity/flutter_launcher_icons.git
  flutter_lints: ^4.0.0
  flutter_test:
    sdk: flutter
  freezed: ^2.4.5
  integration_test:
    sdk: flutter
  json_serializable: ^6.7.1
  mocktail: ^1.0.3
  monarch: ^3.8.0
  riverpod_generator: ^2.3.8
  riverpod_lint: ^2.3.6

flutter_launcher_icons:
  android: "launcher_icon"
  ios: true
  remove_alpha_ios: true
  image_path: "assets/icon/icon.png"
  background_color_ios: "#43B02A"

flutter_native_splash:
  image: assets/images/ggc.png
  color: "#43b02a"

flutter:
  uses-material-design: true
  # Enable generation of localized Strings from arb files.
  generate: true
  assets:
    - assets/images/
    - assets/initialData/
    - assets/monarchData/
    - assets/terms/
    - assets/changelog/
    - assets/help/
    - assets/test/fixture1/
fertrig commented 1 month ago

I need to bump the vm_service dependency in the monarch package. In the meantime, you can try playing with dependency_overrides.

In your pubspec.yaml:

dependency_overrides:
  vm_service: 14.2.1
philipmjohnson commented 1 month ago

Nice! I didn't know about dependency_overrides:! I actually ended up having to override a couple:

dependency_overrides:
  vm_service: 14.2.1 # Due to conflict with monarch 3.8.0
  intl: 0.19.0       # Due to conflict with form_builder_validators 9.1.0

Everything seems to be fine now. Thanks for the quick response.

I'll leave this issue open in case you want to keep it that way until you publish the new release.

chanjungkim commented 1 month ago

Can you check mine too?

name: my_flutter
description: my flutter app

publish_to: 'none' # Remove this line if you wish to publish to pub.dev

version: 1.2.11+39

environment:
  sdk: '>=3.1.0'
  flutter: '>=3.13.0'

dependencies:
  flutter:
    sdk: flutter

  #provider
  flutter_riverpod:
  flutter_hooks:
  hooks_riverpod:
  riverpod_annotation:

  #firebase
  firebase_analytics: ^10.7.1
  firebase_core: ^2.31.0
  firebase_crashlytics: ^3.4.5
  firebase_messaging: ^14.7.5
  firebase_remote_config: ^4.3.17

  #api 통신
  dio:
  dio_http_formatter:
  retrofit:

  async: ^2.11.0
  easy_debounce: ^2.0.3

  rxdart:
  multiple_result: ^5.1.0

  #local storage
  hive:
  hive_flutter:
  flutter_secure_storage:

  #notifications
  flutter_local_notifications:

  #theme
  flutter_screenutil: ^5.9.0
  dotted_line: ^3.2.2
  cupertino_icons: ^1.0.5
  flutter_svg: ^2.0.7

  #navigation
  auto_route:

  #locale
  flutter_localizations:
    sdk: flutter
  intl: any

  #device
  package_info_plus: ^8.0.0
  device_info_plus: ^10.1.0
  android_id: ^0.3.6

  #utils
  freezed:
  freezed_annotation:
  fluttertoast:
  stack_trace:
  logger:
  json_annotation:

  webview_flutter: ^4.7.0
  webview_flutter_android:
  webview_flutter_wkwebview:
  path_provider: ^2.1.3
  multi_masked_formatter: ^1.0.0
  mocktail: ^1.0.1
  datadog_flutter_plugin: ^2.1.1
  datadog_tracking_http_client: ^2.0.0
  collection: ^1.17.2
  url_launcher: ^6.2.1
  lottie: ^3.1.0
  smooth_page_indicator: ^1.1.0
  share_plus: ^9.0.0
  permission_handler: ^11.0.1
  encrypt: ^5.0.3

  # auth
  kakao_flutter_sdk: ^1.7.0
  sign_in_with_apple: ^6.1.0
  flutter_naver_login: ^1.8.0
  google_sign_in: ^6.2.1

  hive_generator: ^2.0.1

  # payment sdk
  tosspayments_widget_sdk_flutter: 2.0.2
  flutter_inappwebview: 6.0.0

  store_redirect: ^2.0.2
  app_tracking_transparency: ^2.0.5

  # ai bot
  path: ^1.8.0
  audioplayers: ^6.0.0
  record: ^5.0.5
  jwt_decoder: ^2.0.1
  dart_openai: ^5.1.0
  fading_edge_scrollview: ^4.1.1

dependency_overrides:
  vm_service: 14.2.1

dev_dependencies:
  flutter_test:
    sdk: flutter
  test: any

  mockito:

  flutter_lints:
  custom_lint:
  riverpod_lint:

  build_runner: ^2.1.11

  riverpod_generator:
  retrofit_generator:
  json_serializable:

  auto_route_generator:
  monarch: ^3.8.1

flutter:

  uses-material-design: true

  assets:
    - assets/animations/
    - assets/images/

  fonts:
    - family: NotoSansKR
      fonts:
        - asset: assets/fonts/NotoSansKR-Thin.otf
          weight: 100
        - asset: assets/fonts/NotoSansKR-Light.otf
          weight: 300
        - asset: assets/fonts/NotoSansKR-Regular.otf
          weight: 400
        - asset: assets/fonts/NotoSansKR-Medium.otf
          weight: 500
        - asset: assets/fonts/NotoSansKR-Bold.otf
          weight: 700
        - asset: assets/fonts/NotoSansKR-Black.otf
          weight: 900
    - family: Pretendard
      fonts:
        - asset: assets/fonts/Pretendard-Thin.otf
          weight: 100
        - asset: assets/fonts/Pretendard-Light.otf
          weight: 300
        - asset: assets/fonts/Pretendard-Regular.otf
          weight: 400
        - asset: assets/fonts/Pretendard-Medium.otf
          weight: 500
        - asset: assets/fonts/Pretendard-Bold.otf
          weight: 700
        - asset: assets/fonts/Pretendard-Black.otf
          weight: 900
    - family: HanSansKR
      fonts:
        - asset: assets/fonts/HanSansKR-Regular.ttf
          weight: 700
    - family: ShiningStarKR
      fonts:
        - asset: assets/fonts/ShiningStarKR-Regular.otf
          weight: 400
fertrig commented 1 month ago

@chanjungkim which error are you getting?

philipmjohnson commented 1 month ago

Oh, I should add that when I added dependency_overrides, it resulted in a bug that appeared only in production mode, not in development mode! So, I have reverted back to Flutter 3.19 and await an upgrade to Monarch before going to Flutter 3.22.

chanjungkim commented 1 month ago

@fertrig It says

We could not find a compatible Monarch UI for this version of Monarch and Flutter.
You could try switching Flutter versions. Or, create a GitHub issue in the Monarch repo 
and let us know which Flutter version your project is using: 

https://github.com/Dropsource/monarch/issues

My versions are

Flutter 3.22.0-0.1.pre • channel beta • https://github.com/flutter/flutter.git Framework • revision 29babcb32a (8 weeks ago) • 2024-04-03 17:17:04 -0500 Engine • revision 97550907b7 Tools • Dart 3.4.0 (build 3.4.0-282.1.beta) • DevTools 2.34.2

When I change Flutter version to 3.19. And Monarch run works there. But I am already using Flutter 3.22 APIs here and there in the current project, So, I cannot rollback the version at the moment.

if there's a way I can debug monarch and fix bug, I would contribute, but it only shows above message and there's nothing I can do. It'd be very nice if march shows detail error message.

fertrig commented 1 month ago

@chanjungkim I'm working on a new release to support Flutter 3.22. Are you on macos, windows, or linux?

fertrig commented 1 month ago

Fix released with Monarch 2.2.7: https://monarchapp.io/blog/version-2.2.7

chanjungkim commented 1 month ago

@fertrig I am using MacOS. I tried with monarch: ^3.8.1 and it's working now. Thanks!

artem-kamyshev commented 2 days ago

@fertrig Sorry to bother you, but I suffer the same issue. This is a fresh project and a first try of both flutter and your tool. I've downloaded the latest monarch from a website.

OS: Windows 10

c:\repos\personal_warehouse>c:\repos\monarch\bin\monarch.exe run Using flutter sdk at C:\FlutterSDK\flutter\bin\flutter

Downloading the Monarch UI for this project's flutter version...

We could not find a compatible Monarch UI for this version of Monarch and Flutter.

c:\repos\personal_warehouse>C:\FlutterSDK\flutter\bin\flutter --version Flutter 3.22.2 • channel stable • https://github.com/flutter/flutter.git Framework • revision 761747bfc5 (4 weeks ago) • 2024-06-05 22:15:13 +0200 Engine • revision edd8546116 Tools • Dart 3.4.3 • DevTools 2.34.3

c:\repos\personal_warehouse>c:\repos\monarch\bin\monarch.exe --version Monarch version 2.2.7

Monarch modules:

  • cli: 3.0.5
  • controller: 1.4.2
  • platform_app: 2.3.1
  • preview_api: 2.4.1

Revision: c5831d1176003a005bcc20ae70e9650be272f118

In dev_dependencies I have monarch: ^3.0.0. I guess it was added by monarch.exe init. I've tried to changed it to ^3.0.5 and the do monarch.exe run but it didn't solved the issue.

Should I open a new issue?

artem-kamyshev commented 14 hours ago

anyway, the version which I built from sources works fine, tnx for creating this utility!