dart-lang / dart-lang/language

Multiple imports in one statement (like variable declarations)

Open
#1,886 2 comments 0 reactions 0 assignees View on GitHub
feature
Dominant language
TeX
Stars
2.9k
Forks
239
Avg merge
2d 18h
Merged PRs (30d)
14

Description

As discussed in other issues, imports can be relatively verbose. So instead of forcing programmers to type `import` every time they want to import something, why not be able to chain imports into one statement?
From
```dart
import "dart:math" as math;
import "dart:async";
import "package:flutter/material.dart";
import "util.dart";
```
to
```dart
import "dart:math" as math, "dart:async", "package:flutter/material.dart", "util.dart";
```
or
```dart
import ["dart:math" as math, "dart:async", "package:flutter/material.dart", "util.dart"];
```
or
```dart
import (
"dart:math" as math,
"dart:async",
"package:flutter/material.dart",
"util.dart"
);
```
To remove ambiguity, maybe imports using `show` or `hide` couldn't be chained in this manner.

Contributor guide

Open the contributing guide

Research direction

Review the proposed chained and parenthesized import syntaxes, including the restriction suggested for imports using show or hide. Determine whether the language design should support this feature and which syntax and ambiguity rules would be acceptable.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.