Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a snippet for the Counter App ๐Ÿงฎ #65

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> 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.
Expand Down
73 changes: 73 additions & 0 deletions snippets/snippets.json
Original file line number Diff line number Diff line change
Expand Up @@ -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<MyHomePage> createState() => _MyHomePageState();",
"}",
"",
"class _MyHomePageState extends State<MyHomePage> {",
" 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: <Widget>[",
" 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": [
Expand Down