Skip to content

Passing no argument to a command that requires one #19

@TheJanzap

Description

@TheJanzap

I've ran into the problem that I've accidentally forgot to pass a argument to a command created with Command.createAsyncNoResult. This has led to the following error in the Debugger.

'package:command_it/async_command.dart': Failed assertion: line 53 pos 9: 'param != null || null is TParam': You passed a null value to the command  that has a non-nullable type as TParam

Is there a way to enforce that the parameter is passed correctly at compile time?

class MyManager {
  // Interacts with a repository that is also final
  late final Command<List<String>, void> testCommand = Command
      .createAsyncNoResult<List<String>>(
          (list) async {
        // do stuff
      });
}

// some other file
testCommand.run() // uh oh

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions