run method

  1. @override
void run()
override

Runs this command.

The return value is wrapped in a Future if necessary and returned by CommandRunner.runCommand.

Implementation

@override
void run() async {
  var widgetName = argResults?['name'] as String?;
  var widgetType = argResults?['type'] as String?;

  widgetName ??= XInput.askValue(
    'Enter Widget Name:',
    null,
    validators: [
      NonEmptyValidator(),
      PascalCaseValidator(),
    ],
  );

  widgetType ??= XInput.askList<String>(
    'Select widget type:',
    ['stateless', 'stateful', 'consumer'],
    defaultAnswer: 'stateless',
  );

  await CreateWidgetTask(
    widgetName: widgetName,
    widgetType: widgetType,
    widgetContent: widgetStub(widgetName, widgetType),
  ).run();
}