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

Suggest imports from custom directories #49137

Open
hyungtaecf opened this issue May 30, 2022 · 3 comments
Open

Suggest imports from custom directories #49137

hyungtaecf opened this issue May 30, 2022 · 3 comments
Labels
analyzer-completion Issues with the analysis server's code completion feature analyzer-quick-fix area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P4 type-enhancement A request for a change that isn't a bug

Comments

@hyungtaecf
Copy link

hyungtaecf commented May 30, 2022

Issue Description

I'm using auto-generated .arb and .dart files for localization in Flutter. It is generated under the directory .dart_tool/flutter_gen/

When using Quick Fix to find AppLocalizations.of(context) it doesn't suggest the import that should be like following:
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

This import is needed for basically every file in the UI that displays text, so it would help a lot if it was possible to get suggested imports from custom directories outside lib/ as well.

What is the fix

Please make a way to customize the directory scope of the import suggestions or make it automatically somehow.

Other information

For now, I am handling this by making another file within the project with the following code:
AppLocalizations l10nOf(BuildContext context) => AppLocalizations.of(context);

@lrhn lrhn added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label May 30, 2022
@jcollins-g jcollins-g added type-enhancement A request for a change that isn't a bug P4 analyzer-completion Issues with the analysis server's code completion feature analyzer-quick-fix labels Jun 1, 2022
@scheglov
Copy link
Contributor

What is the mechanism that adds flutter_gen to a package?
Is .dart_tool/package_config.json somehow updated?
Is there any signal in pubspec.yaml that will say that this package requires such package:flutter_gen generation?

@asashour
Copy link
Contributor

asashour commented Sep 25, 2022

As specified in Flutter internationalization, there are two things in pubspec.yaml:

dependencies:
  flutter_localizations:
    sdk: flutter    # this

flutter:
  generate: true    # and this

@DanTup
Copy link
Collaborator

DanTup commented Oct 6, 2022

There's an open issue at flutter/flutter#102983 about re-thinking how flutter_gen works because it causes quite a few problems (for ex. this also came up at Dart-Code/Dart-Code#3948).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-completion Issues with the analysis server's code completion feature analyzer-quick-fix area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P4 type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests

6 participants