FormatTool class

A dart_dev tool that runs the dart formatter on the current project.

To use this tool in your project, include it in the dart_dev config in tool/dart_dev/config.dart: import 'package:dart_dev/dart_dev.dart';

final config = {
  'format': FormatTool(),
};

This will make it available via the dart_dev command-line app like so: dart run dart_dev format

This tool can be configured by modifying any of its fields: // tool/dart_dev/config.dart import 'package:dart_dev/dart_dev.dart';

final config = {
  'format': FormatTool()
    ..defaultMode = FormatMode.check
    ..exclude = [Glob('lib/src/generated/**.dart')]
    ..formatter = Formatter.dartStyle,
};

It is also possible to run this tool directly in a dart script: FormatTool().run();

Inheritance

Constructors

FormatTool()

Properties

argParser → ArgParser
The argument parser for this tool, if needed.
final
defaultMode FormatMode
The default mode in which to run the formatter.
getter/setter pair
description String?
This tool's description (which is included in the help/usage output) can be overridden by setting this field to a non-null value.
getter/setter pairoverride
exclude List<Glob>?
The globs to exclude from the inputs to the dart formatter.
getter/setter pair
formatter Formatter
The formatter to run, one of:
getter/setter pair
formatterArgs List<String>?
The args to pass to the formatter process run by this command.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
hidden bool
This field determines whether or not this tool is hidden from the help/usage output when running as a part of a command-line app.
getter/setter pairinherited
organizeDirectives bool
If the formatter should also organize imports and exports.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
run([DevToolExecutionContext? context]) FutureOr<int?>
Runs this tool and returns (either synchronously or asynchronously) an int which will be treated as the exit code (i.e. non-zero means failure).
override
toCommand(String name) → Command<int>
Converts this tool to a Command that can be added directly to a CommandRunner, therefore making it executable from the command-line.
inherited
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

getInputs({List<Glob>? exclude, bool? expandCwd, bool? followLinks, String? root, bool? collapseDirectories}) FormatterInputs
Builds and returns the object that contains: