From b599497e976f0bfa5b29cd68625bd7953c0ed7cd Mon Sep 17 00:00:00 2001 From: Moaz El-sawaf <43591891+moazelsawaf@users.noreply.github.com> Date: Sun, 2 Oct 2022 02:00:32 +0200 Subject: [PATCH 1/2] =?UTF-8?q?Added=20a=20snippet=20for=20the=20Counter?= =?UTF-8?q?=20App=20=F0=9F=A7=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- snippets/snippets.json | 73 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/snippets/snippets.json b/snippets/snippets.json index aff8a07..6c821a1 100644 --- a/snippets/snippets.json +++ b/snippets/snippets.json @@ -449,6 +449,79 @@ "}" ] }, + "Counter App": { + "prefix": "counterapp", + "description": "Create the Counter App Flutter Demo", + "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: 'Counter App',", + " theme: ThemeData(", + " primarySwatch: Colors.blue,", + " ),", + " home: const MyHomePage(title: 'Counter App Home Page'),", + " );", + " }", + "}", + "", + "class MyHomePage extends StatefulWidget {", + " const MyHomePage({super.key, required this.title});", + "", + " final String title;", + "", + " @override", + " State createState() => _MyHomePageState();", + "}", + "", + "class _MyHomePageState extends State {", + " int _counter = 0;", + "", + " void _incrementCounter() {", + " setState(() {", + " _counter++;", + " });", + " }", + "", + " @override", + " Widget build(BuildContext context) {", + " return Scaffold(", + " appBar: AppBar(", + " title: Text(widget.title),", + " ),", + " body: Center(", + " child: Column(", + " mainAxisAlignment: MainAxisAlignment.center,", + " children: [", + " const Text(", + " 'You have pushed the button this many times:',", + " ),", + " Text(", + " '$_counter',", + " style: Theme.of(context).textTheme.headline4,", + " ),", + " ],", + " ),", + " ),", + " floatingActionButton: FloatingActionButton(", + " onPressed: _incrementCounter,", + " tooltip: 'Increment',", + " child: const Icon(Icons.add),", + " ),", + " );", + " }", + "}" + ] + }, "Tween Animation Builder": { "prefix": "tweenAnimationBuilder", "body": [ From 4ea4deda61252ca792d63c1efd691ebeb0caeb34 Mon Sep 17 00:00:00 2001 From: Moaz El-sawaf <43591891+moazelsawaf@users.noreply.github.com> Date: Sun, 2 Oct 2022 02:12:27 +0200 Subject: [PATCH 2/2] =?UTF-8?q?Documented=20the=20snippet=20in=20README.md?= =?UTF-8?q?=20=E2=9C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c0e0d05..fb9d167 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ Awesome Flutter Snippets is a collection of commonly used Flutter classes and me | `importAL` | App localisation | Allows for the importation of app_localisation following [generation](https://docs.flutter.dev/development/accessibility-and-localization/internationalization). | `mateapp` | Material App | Create a new Material App. | `cupeapp` | Cupertino Package | Create a New Cupertino App. +| `counterapp` | Counter App | Create the Counter App Flutter Demo. | `tweenAnimationBuilder` | Tween Animation Builder | Widget builder that animates a property of a Widget to a target value whenever the target value changes. | `valueListenableBuilder` | Value Listenable Builder | Given a ValueListenable and a builder which builds widgets from concrete values of T, this class will automatically register itself as a listener of the ValueListenable and call the builder with updated values when the value changes. | `f-group` | Group | Create a group test function.