Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR DART

how to define format snippet of class name as file name in dart : flutter

${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/}

// Example : Snippet of StatefulWidget


"Custom StatefulWidget": {
		"prefix": "bstful",
        "scope": "dart",
		"body": [
			"import 'package:flutter/material.dart';",
			"",
			"class ${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/} extends StatefulWidget {",
			"  const ${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/}({Key? key}) : super(key: key);",
			"",
			"  @override",
			"  State<${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/}> createState() => _${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/}State();",
			"}",
			"",
			"class _${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/}State extends State<${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/}> {",
			"  @override",
			"  Widget build(BuildContext context) {",
			"    return $1($0);",
			"  }",
			"}"
		],
		"description": "Custom StatefulWidget"
	},
 
PREVIOUS NEXT
Tagged: #define #format #snippet #class #file #dart #flutter
ADD COMMENT
Topic
Name
8+1 =