Open hyungtaecf opened 2 years ago
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?
As specified in Flutter internationalization, there are two things in pubspec.yaml
:
dependencies:
flutter_localizations:
sdk: flutter # this
flutter:
generate: true # and this
There's an open issue at https://github.com/flutter/flutter/issues/102983 about re-thinking how flutter_gen
works because it causes quite a few problems (for ex. this also came up at https://github.com/Dart-Code/Dart-Code/issues/3948).
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);