FixImportsTask class tasks

A task that scans dart files for unclean imports and fixes them.

This task consists of two steps, wich are run on all staged dart files:

  1. Make absolute package imports relative
  2. Organize imports

The first step simply checks if any library imports another library from the same package via an absolute package import. If that is the case, the import is simply replaced by a relative one.

The second step collects all imports of the file and the sorts them. They are grouped into dart imports, package imports and relative imports, each group seperated by a newline and the internally sorted alphabetically.

If any of these steps had to modify the file, it saves the changes to the file and returns a TaskResult.modified result.

Implemented types
Available Extensions

Constructors

FixImportsTask({required String packageName, required Directory libDir, required TaskLogger logger})
Default Constructor.
const

Properties

filePattern Pattern
Returns a pattern to check if a RepoEntry can be processed by this task.
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
libDir Directory
The path to the lib folder in this package.
final
logger TaskLogger
The TaskLogger instance used by this task.
final
packageName String
The name if the package that is beeing scanned.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
taskName String
Returns the user-visible name of the task.
no setteroverride

Methods

call(RepoEntry entry) Future<TaskResult>
Executes the task on the given entry.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

current({required TaskLogger logger}) Future<FixImportsTask>
Creates a FixImportsTask based on the current repository.