Flutter

vscode snippet for flutter

Louiey 2025. 5. 29. 15:00
{
    // Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
    // description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
    // is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
    // used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
    // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
    // Placeholders with the same ids are connected.
    // Example:
    // "Print to console": {
    //  "scope": "javascript,typescript",
    //  "prefix": "log",
    //  "body": [
    //      "console.log('$1');",
    //      "$2"
    //  ],
    //  "description": "Log output to console"
    // }
    "flutter clean screen": {
        "prefix": "//-fcs",
        "body": [
            "import 'package:flutter/material.dart';"

            "void main() {"
            "   runApp(const MyApp());"
            "}"

            "class MyApp extends StatelessWidget {"
            "const MyApp({super.key});"
            ""
            "@override"
            "Widget build(BuildContext context) {"
            "    return MaterialApp("
            "    title: 'Flutter Clean',"
            "    debugShowCheckedModeBanner: false,"
            "    theme: ThemeData("
            "        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),"
            "        useMaterial3: true,"
            "    ),"
            "    home: const MyHomePage(title: 'Flutter Clean'),"
            "    );"
            "}"
            "}"
            ""
            "class MyHomePage extends StatefulWidget {"
            "const MyHomePage({super.key, required this.title});"
            ""
            "final String title;"
            ""
            "@override"
            "State<MyHomePage> createState() => _MyHomePageState();"
            "}"
            ""
            "class _MyHomePageState extends State<MyHomePage> {"
            ""            ""
            "@override"
            "Widget build(BuildContext context) {"
            "    return Scaffold("
            "    appBar: AppBar("
            "        backgroundColor: Theme.of(context).colorScheme.inversePrimary,"
            "        title: Text(widget.title),"
            "    ),"
            "    body: const Center("
            "        child: Column("
            "        mainAxisAlignment: MainAxisAlignment.center,"
            "        children: ["
            "            Text("
            "            'Hello Louiey',"
            "            ),"
            "        ],"
            "        ),"
            "    ),"
            "    );"
            "}"
            "}"
        ],
        "description": "louiey flutter clean screen"
    },
    "flutter bottom screen": {
        "prefix": "//-fbs",
        "body": [
            "import 'package:flutter/material.dart';"
            ""
            "void main() {"
            "  runApp(const MyApp());"
            "}"
            ""
            "class MyApp extends StatelessWidget {"
            "  const MyApp({super.key});"
            ""
            "  @override"
            "  Widget build(BuildContext context) {"
            "    return MaterialApp("
            "      title: 'Flutter Demo',"
            "      theme: ThemeData("
            "        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),"
            "        useMaterial3: true,"
            "      ),"
            "      home: const MyHomePage(title: 'TO DO'),"
            "    );"
            "  }"
            "}"
            ""
            "class MyHomePage extends StatefulWidget {"
            "  const MyHomePage({super.key, required this.title});"
            ""
            "  final String title;"
            ""
            "  @override"
            "  State<MyHomePage> createState() => _MyHomePageState();"
            "}"
            ""
            "class _MyHomePageState extends State<MyHomePage> {"
            "  int _selectedIndex = 0;"
            ""
            "  void _onItemTapped(int index) {"
            "    setState(() {"
            "      _selectedIndex = index;"
            "    });"
            "  }"
            ""
            "  @override"
            "  Widget build(BuildContext context) {"
            "    return Scaffold("
            "      appBar: AppBar("
            "        backgroundColor: Theme.of(context).colorScheme.inversePrimary,"
            "        title: Text(widget.title),"
            "      ),"
            "      body: IndexedStack("
            "        index: _selectedIndex,"
            "        children: const ["
            "          // Add screen here"
            "          // VideoScreen(),"
            "        ],"
            "      ),"
            "      bottomNavigationBar: BottomNavigationBar("
            "        items: const ["
            "          BottomNavigationBarItem("
            "              icon: Icon(Icons.video_camera_front_outlined), label: \"Video\"),"
            "          BottomNavigationBarItem("
            "              icon: Icon(Icons.auto_graph_outlined), label: \"Chart\"),"
            "          BottomNavigationBarItem("
            "              icon: Icon(Icons.settings_applications_outlined), label: \"Preference\"),"
            "        ],"
            "        currentIndex: _selectedIndex,"
            "        selectedItemColor: Colors.amber[800],"
            "        onTap: _onItemTapped,"
            "      ),"
            "    );"
            "  }"
            "}"
            ""
        ],
        "description": "louiey flutter bottom navigation bar screen"
    },
    "flutter default screen": {
        "prefix": "//-fds",
        "body": [
            "import 'package:flutter/material.dart';"

            "void main() {"
            "  runApp(const MyApp());"
            "}"

            "class MyApp extends StatelessWidget {"
            "  const MyApp({super.key});"

            "  @override"
            "  Widget build(BuildContext context) {"
            "    return MaterialApp("
            "      title: 'Flutter Demo',"
            "      theme: ThemeData("
            "        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),"
            "        useMaterial3: true,"
            "      ),"
            "      home: const MyHomePage(title: 'Flutter Demo Home Page'),"
            "    );"
            "  }"
            "}"

            "class MyHomePage extends StatefulWidget {"
            "  const MyHomePage({super.key, required this.title});"

            "  final String title;"

            "  @override"
            "  State<MyHomePage> createState() => _MyHomePageState();"
            "}"

            "class _MyHomePageState extends State<MyHomePage> {"
            "  int _counter = 0;"

            "  void _incrementCounter() {"
            "    setState(() {"
            "      _counter++;"
            "    });"
            "  }"

            "  @override"
            "  Widget build(BuildContext context) {"
            "    return Scaffold("
            "      appBar: AppBar("
            "        backgroundColor: Theme.of(context).colorScheme.inversePrimary,"

            "        title: Text(widget.title),"
            "      ),"
            "      body: Center("
            "        child: Column("
            "          mainAxisAlignment: MainAxisAlignment.center,"
            "          children: <Widget>["
            "            const Text('You have pushed the button this many times:'),"
            "            Text("
            "              '$_counter',"
            "              style: Theme.of(context).textTheme.headlineMedium,"
            "            ),"
            "          ],"
            "        ),"
            "      ),"
            "      floatingActionButton: FloatingActionButton("
            "        onPressed: _incrementCounter,"
            "        tooltip: 'Increment',"
            "        child: const Icon(Icons.add),"
            "      ),"
            "    );"
            "  }"
            "}"
        ],
        "description": "flutter default screen"
    },
    "flutter gitignore add": {
        "prefix": "//-fgi",
        "body": [
            "## louiey"
            "/android"
            "/ios"
            "/linux"
            "/macos"
            "/test"
            "/web"
            "/windows"
        ],
        "description": "flutter gitignore"
    },
    "add louiey comment": {
        "prefix": "//-lc",
        "body": [
            "// louiey, $CURRENT_YEAR-$CURRENT_MONTH-$CURRENT_DATE. "
        ],
        "description": "louiey comment"
    },
}