flutter / flutter/flutter-intellij
[Feature Request] Default alias for a file
- Dominant language
- Java
- Stars
- 2k
- Forks
- 356
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 27
Description
## Suggestion
Dart suppose the idea of global scope, and in certain flies it is common to use an alias when importing them. For example:
```
import 'package:path/path.dart' as path;
import 'package:http/http.dart' as http;
```
When you try to use an object (variable/method/etc) from a flie that exist in the global namespace, intellij will suggest importing the specific file, but will import it without the alias.
It would be nice if one could mark a specific file as an alias, so when IntelliJ would import the file it would automatically use the alias
## How would it look once the feature is implemented
1. Create a file and add a const variable in the global namespace, such as `app_constants.dart` with:
```
const app_name = 'MyApp';
```
2. Mark the file `app_constants.dart` as having an alias of `app_consts`. This step can be done in project settings or by right clicking a file. Any way is fine to begin with.
3. In another source file, use the app_name (without importing `app_constants.dart` file):
```
return Text(app_name);
```
4. IntelliJ will now suggest you auto-import `app_name`. If you've chosen, the result file will look like this:
```
import 'package:myapp/app_constants.dart' as app_consts;
return Text(app_consts.app_name);
```
Contributor guide
Assessment
This issue has not been assessed yet.