createFlutterProject method

Future<void> createFlutterProject({
  1. required HookContext context,
  2. required String name,
  3. required String description,
  4. required String outputPath,
  5. String template = 'app',
  6. List<String> platforms = const ['ios', 'android', 'web'],
  7. String? orgName,
})

Creates a new Flutter project.

context - The Mason hook context name - The name of the project description - A description of the project outputPath - Where to create the project template - The project template to use ('app', 'package', 'plugin') platforms - Target platforms for the project orgName - Organization name (bundle identifier prefix)

Implementation

Future<void> createFlutterProject({
  required HookContext context,
  required String name,
  required String description,
  required String outputPath,
  String template = 'app',
  List<String> platforms = const ['ios', 'android', 'web'],
  String? orgName,
}) =>
    trackOperation(
      context,
      startMessage: 'Creating Flutter $template project: $name',
      endMessage: 'Flutter project created successfully',
      operation: () {
        final args = [
          'create',
          name,
          '--template=$template',
          if (template != 'package') '--platforms=${platforms.join(",")}',
          '--description=$description',
        ];

        if (orgName != null) {
          args.add('--org=$orgName');
        }

        return Process.run(
          'flutter',
          args,
          workingDirectory: outputPath,
          runInShell: true,
        );
      },
    );