|
| 1 | +# Flutter Snippets Helper |
| 2 | + |
| 3 | +Essential Flutter widget snippets for rapid development. This extension provides commonly used Flutter widgets and patterns as snippets to speed up your development workflow. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +This extension includes snippets for: |
| 8 | + |
| 9 | +### Basic Widgets |
| 10 | + |
| 11 | +- `stless` → Creates a StatelessWidget |
| 12 | + |
| 13 | + ```dart |
| 14 | + class WidgetName extends StatelessWidget { |
| 15 | + const WidgetName({super.key}); |
| 16 | +
|
| 17 | + @override |
| 18 | + Widget build(BuildContext context) { |
| 19 | + return Container(); |
| 20 | + } |
| 21 | + } |
| 22 | + ``` |
| 23 | + |
| 24 | +- `stful` → Creates a StatefulWidget |
| 25 | + |
| 26 | + ```dart |
| 27 | + class WidgetName extends StatefulWidget { |
| 28 | + const WidgetName({super.key}); |
| 29 | +
|
| 30 | + @override |
| 31 | + State<WidgetName> createState() => _WidgetNameState(); |
| 32 | + } |
| 33 | +
|
| 34 | + class _WidgetNameState extends State<WidgetName> { |
| 35 | + @override |
| 36 | + Widget build(BuildContext context) { |
| 37 | + return Container(); |
| 38 | + } |
| 39 | + } |
| 40 | + ``` |
| 41 | + |
| 42 | +### Layout Widgets |
| 43 | + |
| 44 | +- `col` → Column with alignment options |
| 45 | +- `row` → Row with alignment options |
| 46 | +- `stack` → Stack with Positioned child |
| 47 | +- `cont` → Container with decoration and shadow |
| 48 | +- `responsive` → Responsive layout builder |
| 49 | + |
| 50 | +### List & Grid Widgets |
| 51 | + |
| 52 | +- `lvb` → ListView.builder |
| 53 | + ```dart |
| 54 | + ListView.builder( |
| 55 | + itemCount: items.length, |
| 56 | + itemBuilder: (context, index) { |
| 57 | + return ListTile( |
| 58 | + title: Text('Item $index'), |
| 59 | + ); |
| 60 | + }, |
| 61 | + ) |
| 62 | + ``` |
| 63 | +- `gvb` → GridView.builder with customizable parameters |
| 64 | + |
| 65 | +### Navigation & Structure |
| 66 | + |
| 67 | +- `scaffold` → Scaffold with AppBar and FloatingActionButton |
| 68 | +- `appbar` → Custom AppBar with leading and actions |
| 69 | +- `drawer` → Navigation Drawer with header |
| 70 | +- `tabs` → TabBar with TabBarView |
| 71 | +- `matapp` → MaterialApp with theme setup |
| 72 | + |
| 73 | +### Async Widgets |
| 74 | + |
| 75 | +- `fb` → FutureBuilder with loading and error handling |
| 76 | + ```dart |
| 77 | + FutureBuilder<dynamic>( |
| 78 | + future: myFuture, |
| 79 | + builder: (context, snapshot) { |
| 80 | + if (snapshot.connectionState == ConnectionState.waiting) { |
| 81 | + return const CircularProgressIndicator(); |
| 82 | + } |
| 83 | + if (snapshot.hasError) { |
| 84 | + return Text('Error: ${snapshot.error}'); |
| 85 | + } |
| 86 | + return Container(); |
| 87 | + }, |
| 88 | + ) |
| 89 | + ``` |
| 90 | +- `sb` → StreamBuilder with loading and error handling |
| 91 | + |
| 92 | +### State Management |
| 93 | + |
| 94 | +- `providerclass` → Provider ChangeNotifier class |
| 95 | + |
| 96 | + ```dart |
| 97 | + class MyProvider extends ChangeNotifier { |
| 98 | + int _value = 0; |
| 99 | + int get value => _value; |
| 100 | +
|
| 101 | + void updateValue(int newValue) { |
| 102 | + _value = newValue; |
| 103 | + notifyListeners(); |
| 104 | + } |
| 105 | + } |
| 106 | + ``` |
| 107 | + |
| 108 | +- `getxc` → GetX Controller class |
| 109 | +- `bloc` → BLoC class with event handler |
| 110 | + |
| 111 | +### UI Components |
| 112 | + |
| 113 | +- `card` → Card with padding and content |
| 114 | +- `btn` → Styled ElevatedButton |
| 115 | +- `form` → Form with validation |
| 116 | +- `animcont` → AnimatedContainer with duration |
| 117 | +- `pageview` → PageView with controller |
| 118 | + |
| 119 | +## Usage |
| 120 | + |
| 121 | +1. Install the extension |
| 122 | +2. Open a `.dart` file |
| 123 | +3. Start typing the snippet prefix (e.g., `stless`) |
| 124 | +4. Press `Tab` to insert the snippet |
| 125 | +5. Use `Tab` to navigate through the placeholders |
| 126 | + |
| 127 | +## Examples |
| 128 | + |
| 129 | +### Creating a Form |
| 130 | + |
| 131 | +```dart |
| 132 | +// Type 'form' and press Tab |
| 133 | +final _formKey = GlobalKey<FormState>(); |
| 134 | +
|
| 135 | +Form( |
| 136 | + key: _formKey, |
| 137 | + child: Column( |
| 138 | + children: [ |
| 139 | + TextFormField( |
| 140 | + decoration: const InputDecoration( |
| 141 | + labelText: 'Label', |
| 142 | + hintText: 'Enter text', |
| 143 | + ), |
| 144 | + validator: (value) { |
| 145 | + if (value == null || value.isEmpty) { |
| 146 | + return 'Please enter some text'; |
| 147 | + } |
| 148 | + return null; |
| 149 | + }, |
| 150 | + ), |
| 151 | + ElevatedButton( |
| 152 | + onPressed: () { |
| 153 | + if (_formKey.currentState!.validate()) { |
| 154 | + // Process data |
| 155 | + } |
| 156 | + }, |
| 157 | + child: const Text('Submit'), |
| 158 | + ), |
| 159 | + ], |
| 160 | + ), |
| 161 | +) |
| 162 | +``` |
| 163 | + |
| 164 | +### Creating a Responsive Layout |
| 165 | + |
| 166 | +```dart |
| 167 | +// Type 'responsive' and press Tab |
| 168 | +LayoutBuilder( |
| 169 | + builder: (context, constraints) { |
| 170 | + if (constraints.maxWidth < 600) { |
| 171 | + return // Mobile layout |
| 172 | + } else if (constraints.maxWidth < 900) { |
| 173 | + return // Tablet layout |
| 174 | + } else { |
| 175 | + return // Desktop layout |
| 176 | + } |
| 177 | + }, |
| 178 | +) |
| 179 | +``` |
| 180 | + |
| 181 | +## Requirements |
| 182 | + |
| 183 | +- VS Code 1.93.0 or higher |
| 184 | +- Dart/Flutter extension installed |
| 185 | + |
| 186 | +## Known Issues |
| 187 | + |
| 188 | +None at the moment. Please report any issues on our GitHub repository. |
| 189 | + |
| 190 | +## Release Notes |
| 191 | + |
| 192 | +### 0.0.2 |
| 193 | + |
| 194 | +- Added comprehensive snippets documentation |
| 195 | +- Added icon and improved package metadata |
| 196 | +- Fixed snippet formatting issues |
| 197 | + |
| 198 | +### 0.0.1 |
| 199 | + |
| 200 | +- Initial release with essential Flutter snippets |
| 201 | +- Basic widget templates |
| 202 | +- Layout widgets |
| 203 | +- Navigation patterns |
| 204 | +- State management templates |
| 205 | +- Form and validation snippets |
| 206 | + |
| 207 | +## Contributing |
| 208 | + |
| 209 | +Feel free to submit issues and enhancement requests on our GitHub repository. |
| 210 | + |
| 211 | +## Working with the Extension |
| 212 | + |
| 213 | +- Press `Ctrl+Space` (Windows, Linux, macOS) to see all available snippets |
| 214 | +- Type the snippet prefix (e.g., `stless`) and press `Tab` |
| 215 | +- Use `Tab` to navigate through the snippet placeholders |
| 216 | + |
| 217 | +## For more information |
| 218 | + |
| 219 | +- [Flutter Documentation](https://flutter.dev/docs) |
| 220 | +- [VS Code Extension Guidelines](https://code.visualstudio.com/api/references/extension-guidelines) |
| 221 | +- [Extension Repository](https://github.com/yourusername/flutter-snippets-helper) |
| 222 | + |
| 223 | +**Enjoy coding Flutter faster!** |
0 commit comments