Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add 'generate: true' to support in workspaces #4471

Open
abikko opened this issue Dec 13, 2024 · 8 comments
Open

add 'generate: true' to support in workspaces #4471

abikko opened this issue Dec 13, 2024 · 8 comments

Comments

@abikko
Copy link

abikko commented Dec 13, 2024

Environment

  • Dart version (run dart --version): Dart SDK version: 3.6.0 (stable) (Thu Dec 5 07:46:24 2024 -0800) on "macos_arm64"
  • OS kind and version (e.g. "Windows 10, version 1809" or "macOS 12.4"): macOS 15.1.1
  • Are you using the Chinese community mirror or a corporate firewall? - No

Problem

Currently, I have project which currently is using intl package,

and I generate messages from arb using the command 'flutter gen-l10n' with generate: true

but when I trying to run 'flutter pub get' in workspace - terminal giving me error 'generate: true is not supported within workspaces.'

So, I removed 'generate: true' in pubspec.yaml, and I have another error:
"Attempted to generate localizations code without having the flutter: generate flag turned on.
Check pubspec.yaml and ensure that flutter: generate: true has been added and rebuild the project. Otherwise, the localizations source code will not be importable."

name: admin
description: New Admin on Flutter
version: 1.0.0+1
publish_to: none

environment:
  sdk: ^3.6.0
resolution: workspace

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter

dev_dependencies:
  build_runner: ^2.4.12
  flutter_test:
    sdk: flutter

flutter:
  uses-material-design: true
  assets:
    - assets/icons/
    - assets/

Expected behavior

Generate AppLocalizations - dart class

Actual behavior

Giving error
"Attempted to generate localizations code without having the flutter: generate flag turned on.
Check pubspec.yaml and ensure that flutter: generate: true has been added and rebuild the project. Otherwise, the localizations source code will not be importable."

@sigurdm
Copy link
Contributor

sigurdm commented Dec 13, 2024

Oh - this will not be trivial to support. This needs to be supported in the flutter tool

The tool could run dart pub workspace list to find all pubspecs, and iterate through them to see which to generate for.

In general I think we are considering moving away from the flutter: generate internationalization method.

I'd suggest using one of the alternative ways of generating internationalization support :
https://docs.flutter.dev/ui/accessibility-and-internationalization/internationalization#alternative-internationalization-workflows

@sigurdm
Copy link
Contributor

sigurdm commented Dec 13, 2024

cc @bkonyi

@sigurdm
Copy link
Contributor

sigurdm commented Dec 13, 2024

Linking to flutter/flutter#160151

@sigurdm
Copy link
Contributor

sigurdm commented Dec 13, 2024

Issue for deprecation of flutter_gen: flutter/flutter#102983

@abikko
Copy link
Author

abikko commented Dec 13, 2024

Thanks!

Helped this reply: flutter/flutter#160151 (comment)

@abikko abikko closed this as completed Dec 13, 2024
@sigurdm
Copy link
Contributor

sigurdm commented Dec 13, 2024

Hmm - we should probably fix this in general, but nice that the workaround exists!

@sigurdm sigurdm reopened this Dec 13, 2024
@bkonyi
Copy link
Contributor

bkonyi commented Dec 13, 2024

Yeah, the plan is to remove flutter_gen in a future release but I'm not sure what the timeline is on that (cc @matanlurey). If this is going to be a lot of work to support in pub workspaces, we should probably just direct users to migration documentation so they can move off this deprecated implementation.

@matanlurey
Copy link
Contributor

I plan to disable it by default in the upcoming stable release (can still be opted-back into) and then removed in the following.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants