4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【ちょっと便利な小技_part 8】 お気に入り自作スニペット編

Last updated at Posted at 2023-09-07

今回は下記の2つの記事の内容を合わせた自分のお気に入り自作スニペットを紹介します。
コピペで使えるので是非使ってみてください。

コピペで使えるお気に入り自作スニペット紹介

StatelessWidget+ファイル名に合わせたクラス名+import

dart.json
"Stateless tmp": {
		"prefix": "lesstmp",
		"body": [
			"import 'package:flutter/material.dart';",
			"",
			"class ${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/g} extends StatelessWidget {",
			"  const ${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/g}({Key? key}) : super(key: key);",
			"",
			"  @override",
			"  Widget build(BuildContext context) {",
			"    return Scaffold(",
			"      appBar: AppBar(",
			"        title: Text(\"\"),",
			"      ),",
			"      body: Container(),",
			"    );",
			"  }",
			"}"
		],
		"description": "Stateless tmp"
	},

StatefulWidget+ファイル名に合わせたクラス名+import

dart.json
"Stateful tmp": {
		"prefix": "fultmp",
		"body": [
			"import 'package:flutter/material.dart';",
			"",
			"class ${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/g} extends StatefulWidget {",
			"  const ${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/g}({Key? key}) : super(key: key);",
			"",
			"  @override",
			"  State<${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/g}> createState() => _${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/g}State();",
			"}",
			"",
			"class _${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/g}State extends State<${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/g}> {",
			"  @override",
			"  Widget build(BuildContext context) {",
			"    return Scaffold(",
			"      appBar: AppBar(",
			"        title: Text(\"\"),",
			"      ),",
			"      body: Container(),",
			"    );",
			"  }",
			"}"
		],
		"description": "Stateful tmp"
	},
4
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?