2020-04-26 01:56:16 +00:00
|
|
|
# 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 {
|
2023-04-01 20:48:04 +00:00
|
|
|
const $1({super.key});
|
|
|
|
|
2020-04-26 01:56:16 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Container(
|
|
|
|
$2
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Flutter stateful widget
|
|
|
|
snippet stful
|
|
|
|
class $1 extends StatefulWidget {
|
2023-04-01 20:48:04 +00:00
|
|
|
const $1({super.key});
|
|
|
|
|
2020-04-26 01:56:16 +00:00
|
|
|
@override
|
2023-04-01 20:48:04 +00:00
|
|
|
State<$1> createState() => _$1State();
|
2020-04-26 01:56:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class _$1State extends State<$1> {
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Container(
|
|
|
|
$2
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Flutter widget with AnimationController
|
|
|
|
snippet stanim
|
|
|
|
class $1 extends StatefulWidget {
|
2023-04-01 20:48:04 +00:00
|
|
|
const $1({super.key});
|
|
|
|
|
2020-04-26 01:56:16 +00:00
|
|
|
@override
|
2023-04-01 20:48:04 +00:00
|
|
|
State<$1> createState() => _$1State();
|
2020-04-26 01:56:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2022-08-08 13:45:56 +00:00
|
|
|
|
|
|
|
# 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'),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|