Skip to content

Instantly share code, notes, and snippets.

@esDotDev
Last active January 25, 2024 06:39
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save esDotDev/7e14fb1966ccbbad9b1af1d06696d4cb to your computer and use it in GitHub Desktop.
Save esDotDev/7e14fb1966ccbbad9b1af1d06696d4cb to your computer and use it in GitHub Desktop.
import os
org = "com.example"
name = "app_name"
cmd = "flutter create --org " + org + " --project-name " + name + " .";
packages = [
"cached_network_image",
"collection",
"copy_with_extension",
"equatable",
"extra_alignments",
"flextras",
"gap",
"get_it",
"get_it_mixin",
"json_annotation",
"modal_bottom_sheet",
"reactives",
"simple_rich_text",
"sized_context"
];
for p in packages:
cmd += " && flutter pub add " + packages[packages.index(p)]
packages = [
"build_runner",
"copy_with_extension_gen",
"json_serializable",
];
for p in packages:
cmd += " && flutter pub add " + packages[packages.index(p)]
# Create project
os.system(cmd);
# Replace main file
main = """import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: Center(child: FlutterLogo()),
);
}
}"""
mainPath = "lib/main.dart";
os.remove(mainPath);
f = open(mainPath, "a")
f.write(main)
f.close()
@avioli
Copy link

avioli commented Sep 16, 2022

Thanks for the script. You have missed --dev when adding dev packages ;)

@AhmedBenCheikh
Copy link

thanks for sharing, very helpful, we should add this with mac m1 chip
#!/usr/bin/env python3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment