initFolders method

Future<void> initFolders({
  1. bool setUpPackage = false,
})

Implementation

Future<void> initFolders({bool setUpPackage = false}) async {
  try {
    final appInfo = await _getUserApplicationData();
    final repoUrl =
        "https://github.com/abdAlftahSalem/flutter_getx_template.git";
    final dirName = appInfo['appName'] ?? "";

    print(
        "\n\nšŸ”ƒšŸ”ƒ Thunder will initialize your app. Please wait for seconds");

    final cloneExitCode = await _cloneRepository(repoUrl, dirName);

    if (cloneExitCode == 0) {
      final success = await _setupClonedProject(appInfo);

      if (success) {
        print('āš” Init app successfully\n');

        await _publishToGitHub();

        final openInVSCode = await _askToOpenInVSCode();

        if (openInVSCode) {
          print('āš” Opening project in VSCode...');
          await _openInVSCode();
        }
      } else {
        print('šŸ˜… An error occurred during project setup.');
      }
    } else {
      print('šŸ˜… Failed to clone the repository.');
    }
  } catch (e) {
    print('šŸ˜… An error occurred: $e');
  }
}