Skip to content

Commit 6035380

Browse files
authored
Remove an unnecessary dynamic (#2239)
The `dynamic` was used to satisfy the purpose that is more directly expressed with `FutureOr`. Replace the private `_Command` class with a typedef record with named fields.
1 parent 43ad4cd commit 6035380

File tree

1 file changed

+8
-16
lines changed

1 file changed

+8
-16
lines changed

pkgs/test_core/lib/src/runner/console.dart

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ class Console {
4747
///
4848
/// The [description] should be a one-line description of the command to print
4949
/// in the help output. The [body] callback will be called when the user types
50-
/// the command, and may return a [Future].
50+
/// the command.
5151
void registerCommand(
52-
String name, String description, dynamic Function() body) {
52+
String name, String description, FutureOr<void> Function() body) {
5353
if (_commands.containsKey(name)) {
5454
throw ArgumentError('The console already has a command named "$name".');
5555
}
5656

57-
_commands[name] = _Command(name, description, body);
57+
_commands[name] = (name: name, description: description, body: body);
5858
}
5959

6060
/// Starts running the console.
@@ -102,16 +102,8 @@ class Console {
102102
}
103103
}
104104

105-
/// An individual console command.
106-
class _Command {
107-
/// The name of the command.
108-
final String name;
109-
110-
/// The single-line description of the command.
111-
final String description;
112-
113-
/// The callback to run when the command is invoked.
114-
final dynamic Function() body;
115-
116-
_Command(this.name, this.description, this.body);
117-
}
105+
typedef _Command = ({
106+
String name,
107+
String description,
108+
FutureOr<void> Function() body,
109+
});

0 commit comments

Comments
 (0)