diff options
| author | Vito G. Graffagnino <vito@graffagnino.xyz> | 2022-08-28 12:24:01 +0100 |
|---|---|---|
| committer | Vito G. Graffagnino <vito@graffagnino.xyz> | 2022-08-28 12:24:01 +0100 |
| commit | 823302458ec6c53455a3f34674415c43ce6a3187 (patch) | |
| tree | 92168b44b01f5b2236b7cdf331e227c4790431ee /snippets/dart-flutter.snippets | |
| parent | 9ea6111717518625cbd28a020493ec06610ff01e (diff) | |
Added snippets directory
Diffstat (limited to 'snippets/dart-flutter.snippets')
| -rw-r--r-- | snippets/dart-flutter.snippets | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/snippets/dart-flutter.snippets b/snippets/dart-flutter.snippets new file mode 100644 index 0000000..f51f11c --- /dev/null +++ b/snippets/dart-flutter.snippets @@ -0,0 +1,89 @@ +# Snippets for dart in flutter project, to use add the following to your .vimrc +# `autocmd BufRead,BufNewFile,BufEnter *.dart UltiSnipsAddFiletypes dart-flutter` +# Flutter stateless widget +snippet stless + class $1 extends StatelessWidget { + @override + Widget build(BuildContext context) { + return Container( + $2 + ); + } + } + +# Flutter stateful widget +snippet stful + class $1 extends StatefulWidget { + @override + _$1State createState() => _$1State(); + } + + class _$1State extends State<$1> { + @override + Widget build(BuildContext context) { + return Container( + $2 + ); + } + } + +# Flutter widget with AnimationController +snippet stanim + class $1 extends StatefulWidget { + @override + _$1State createState() => _$1State(); + } + + class _$1State extends State<$1> + with SingleTickerProviderStateMixin { + AnimationController _controller; + + @override + void initState() { + super.initState(); + _controller = AnimationController(vsync: this); + } + + @override + void dispose() { + super.dispose(); + _controller.dispose(); + } + + @override + Widget build(BuildContext context) { + return Container( + $2 + ); + } + } + +# Flutter scaffold application +snippet fsa + void main() { + runApp( + MaterialApp( + title: 'Flutter Demo', + theme: ThemeData( + primarySwatch: Colors.blue, + ), + debugShowCheckedModeBanner: false, + home: const HomePage(), + ), + ); + } + + class HomePage extends StatelessWidget { + const HomePage({Key? key}) : super(key: key); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: const Text('Home Page'), + ), + ); + } + } + + |
