Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove an unnecessary dynamic #2239

Merged
merged 4 commits into from
Jun 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 8 additions & 16 deletions pkgs/test_core/lib/src/runner/console.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ class Console {
///
/// The [description] should be a one-line description of the command to print
/// in the help output. The [body] callback will be called when the user types
/// the command, and may return a [Future].
/// the command.
void registerCommand(
String name, String description, dynamic Function() body) {
String name, String description, FutureOr<void> Function() body) {
if (_commands.containsKey(name)) {
throw ArgumentError('The console already has a command named "$name".');
}

_commands[name] = _Command(name, description, body);
_commands[name] = (name: name, description: description, body: body);
}

/// Starts running the console.
Expand Down Expand Up @@ -102,16 +102,8 @@ class Console {
}
}

/// An individual console command.
class _Command {
kevmoo marked this conversation as resolved.
Show resolved Hide resolved
/// The name of the command.
final String name;

/// The single-line description of the command.
final String description;

/// The callback to run when the command is invoked.
final dynamic Function() body;

_Command(this.name, this.description, this.body);
}
typedef _Command = ({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That works, too!

String name,
String description,
FutureOr<void> Function() body,
});
Loading