{
	"parse-model": {
		"prefix": "dw prsemdl",
		"body": [
			"class ${1:YourModel} extends ParseObject implements ParseCloneable {",
			"${1:YourModel}() : super(_keyTableName);",
			"${1:YourModel}.clone() : this();",
			"static const String _keyTableName = '${2:YourModel}';",
			"@override",
			"clone(Map<String, dynamic> map) => ${1:YourModel}.clone()..fromJson(map);",
			"}"
		],
	},
	"parse-property": {
		"prefix": "dw prseprop",
		"body": [
			"static const String _$1 = '$1';",
			"${3:String}? get $1 => get<${3:String}>(_$1);",
			"set $1(${3:String}? value) => set<${3:String}>(_$1, value!);"
		]
	},
	"parse-query-builder": {
		"prefix": "dw parsequery",
		"body": [
			"QueryBuilder<${1:ParseObject}> ${2:query} =",
			"QueryBuilder(${1:ParseObject}('${3:}'))"
		],
		"description": "create query builder parse"
	},
	"parse-cloud-function": {
		"prefix": "dw parsecloudfunction",
		"body": [
			"final ParseCloudFunction ${1:function} = ParseCloudFunction('$2');",
			"final Map<String, dynamic> ${3:params} = <String, dynamic>{",
			"'${4:parameter1}': ${5:value},",
			"};"
		],
		"description": "create cloud function boilerplate"
	},
	"parse-api-response-query": {
		"prefix": "dw parseapiresquery",
		"body": [
			"ParseResponse apiResponse = await ${1:query}.query();",
			"if (apiResponse.success && apiResponse.results!=null) {",
			"print('$3');",
			"var list = apiResponse.results!.cast<${2:Model}>();",
			"return list;",
			"} else {",
			"return Future.error(apiResponse.error!.message);",
			"}"
		],
		"description": "create parse server api response query"
	},
	"parse-api-response-execute": {
		"prefix": "dw parseapiresexecute",
		"body": [
			"final ParseResponse ${1:apiResponse} = await function.execute(parameters: ${2:params});",
			"if (apiResponse.success && apiResponse.results!=null) {",
			"print(${3:apiResponse.result});",
			"} else {",
			"return Future.error(apiResponse.error!.message);",
			"}"
		],
		"description": "create parse server api response execute"
	},
	"parse-api-response-save": {
		"prefix": "dw parseapiressave",
		"body": [
			"final ParseResponse ${1:apiResponse} = await $2.save();",
			"if (apiResponse.success) {",
			"print('${3:success save}');",
			"} else {",
			"return Future.error(apiResponse.error!.message);",
			"}"
		],
		"description": "create parse server api response save"
	},
	"from-json-model": {
		"prefix": "dw fromjsontojson",
		"body": [
			"factory ${1:ClassModelModel}.fromJson(Map<String, dynamic> json) =>",
			"_$${1:ClassModelModel}FromJson(json);",
			"Map<String, dynamic> toJson() => _$${1:ClassModelModel}ToJson(this);",
			"factory ${1:ClassModelModel}.fromFirestore(DocumentSnapshot doc) =>",
			"${1:ClassModelModel}.fromJson(doc.data()! as Map<String, dynamic>)..id = doc.id;"
		],
		"description": "from json model dan to json"
	},
	"datetime-from-json": {
		"prefix": "dw fromjsondatetime",
		"body": [
			"static DateTime? _dateTimeFromJson(Timestamp? timestamp) => timestamp?.toDate();",
			"static Timestamp? _dateTimeToJson(DateTime? dateTime) {",
			"  if(dateTime==null) return null;",
			"  return Timestamp.fromDate(dateTime);",
			"}"
		],
		"description": "from json model dan to json"
	},
	"class-model": {
		"prefix": "dw classmodel",
		"body": [
			"import 'package:cloud_firestore/cloud_firestore.dart';",
			"import 'package:json_annotation/json_annotation.dart';",
			"part '$TM_FILENAME_BASE.g.dart';",
			"@JsonSerializable(ignoreUnannotated: true)",
			"class ${1:ClassModelName} {",
			"String? id;",
			"${1:ClassModelName}({this.id});",
			"factory ${1:ClassModelModel}.fromJson(Map<String, dynamic> json) =>",
			"_$${1:ClassModelModel}FromJson(json);",
			"Map<String, dynamic> toJson() => _$${1:ClassModelModel}ToJson(this);",
			"factory ${1:ClassModelModel}.fromFirestore(DocumentSnapshot doc) =>",
			"${1:ClassModelModel}.fromJson(doc.data()! as Map<String, dynamic>)..id = doc.id;",
			"}"
		],
		"description": "class model"
	},
	"print-dart": {
		"prefix": "dw print",
		"body": [
			"print('${1} : '+${1});",
		],
		"description": "class model"
	},
	"future-function": {
		"prefix": "dw future function",
		"body": [
			"Future${2} ${1}() async {",
			"try {",
			"${3}",
			"} catch (e) {",
			"return Future.error(e);",
			"}",
			"}"
		],
		"description": "create future function"
	},
	"tojson-model": {
		"prefix": "dw tojsonmodel",
		"body": [
			"static Map<String, dynamic>? ${1/(.*)/${1:/downcase}/}ToJson(${1}? ${1/(.*)/${1:/downcase}/}) =>",
			"${1/(.*)/${1:/downcase}/}?.toJson();"
		],
		"description": "create model to json annotation Json(toJson:modelToJson)"
	},
	"list-body-container": {
		"prefix": "dw obx list body container",
		"body": [
			"Container(",
			"child: Column(children: [",
			" Expanded(",
			"child: controller.obx(",
			"(${1:list}) => ListView.builder(",
			"padding: EdgeInsets.only(top: 10.0),",
			"itemCount: ${1:list}!.length,",
			"itemBuilder: (context, index) {",
			"return ${2:ListTile}(title:Text(${1:list}[index]) );",
			"},",
			"),",
			"onEmpty: Center(child: EmptyList(msg: 'No Data'.tr))),",
			")",
			"]),",
			"),",
		],
		"description": "create model to json annotation Json(toJson:modelToJson)"
	},
	"Class Model Freezed": {
		"prefix": "dw class model freezed",
		"body": [
			"import 'package:cloud_firestore/cloud_firestore.dart';",
			"import 'package:freezed_annotation/freezed_annotation.dart';",
			"part '$TM_FILENAME_BASE.g.dart';",
			"part '$TM_FILENAME_BASE.freezed.dart';",
			"@freezed\nclass ${1:ClassModelName}Model with _$${1:ClassModelName}Model {",
			"  const factory ${1:ClassModelName}Model({",
			"    String? id,",
			"@TimestampConverter() DateTime? createdAt,",
			"  }) = _${1:ClassModelName}Model;",
			"",
			"  factory ${1:ClassModelName}Model.fromJson(Map<String, dynamic> json) =>",
			"      _$${1:ClassModelName}ModelFromJson(json);",
			"",
			"  factory ${1:ClassModelName}Model.fromFirestore(DocumentSnapshot doc) {",
			"    final data = doc.data() as Map<String, dynamic>;",
			"    data['id'] = doc.id;",
			"    return ${1:ClassModelName}Model.fromJson(data);",
			"  }",
			"}"
		],
		"description": "Creates a new ${1:ClassModelName}Model class with fromFirestore factory constructor"
	},
	"Class Model Freezed AppWrite": {
		"prefix": "dw class model freezed",
		"body": [
			"import 'package:freezed_annotation/freezed_annotation.dart';",
			"part '$TM_FILENAME_BASE.g.dart';",
			"part '$TM_FILENAME_BASE.freezed.dart';",
			"@freezed\nclass ${1:ClassModelName}Model with _$${1:ClassModelName}Model {",
			"  const factory ${1:ClassModelName}Model({",
			"    @JsonKey(name: '\\$id') String? id,",
			"    @TimestampConverter() DateTime? createdAt,",
			"  }) = _${1:ClassModelName}Model;",
			"",
			"  factory ${1:ClassModelName}Model.fromJson(Map<String, dynamic> json) =>",
			"      _$${1:ClassModelName}ModelFromJson(json);",
			"",
			"}"
		],
		"description": "Creates a new ${1:ClassModelName}Model class with fromFirestore factory constructor"
	},
	"Class Model Freezed & Hive": {
		"prefix": "dw class model freezed hive",
		"body": [
			"import 'package:cloud_firestore/cloud_firestore.dart';",
			"import 'package:freezed_annotation/freezed_annotation.dart';",
			"import 'package:hive_flutter/hive_flutter.dart';",
			"part '$TM_FILENAME_BASE.g.dart';",
			"part '$TM_FILENAME_BASE.freezed.dart';",
			"@HiveType(typeId: ${2:0})",
			"@freezed",
			"class ${1:ClassModelName}Model with _$${1:ClassModelName}Model {",
			"  const factory ${1:ClassModelName}Model({",
			"   @HiveField(1) String? id,",
			"@HiveField(2) @TimestampConverter() DateTime? createdAt,",
			"  }) = _${1:ClassModelName}Model;",
			"",
			"  factory ${1:ClassModelName}Model.fromJson(Map<String, dynamic> json) =>",
			"      _$${1:ClassModelName}ModelFromJson(json);",
			"",
			"  factory ${1:ClassModelName}Model.fromFirestore(DocumentSnapshot doc) {",
			"    final data = doc.data() as Map<String, dynamic>;",
			"    data['id'] = doc.id;",
			"    return ${1:ClassModelName}Model.fromJson(data);",
			"  }",
			"}"
		],
		"description": "Creates a new ${1:ClassModelName}Model class with fromFirestore factory constructor with freezed & hive"
	},
	"form builder confirmation": {
		"prefix": "dw form builder confirmation",
		"body": [
			"if (formKey.currentState!.validate()) {",
			"  formKey.currentState!.save();",
			"  var data = await Get.defaultDialog<bool>(",
			"    title: 'Confirmation',",
			"    middleText: '${1:message}'.tr,",
			"    textCancel: 'Cancel',",
			"    textConfirm: 'OK',",
			"    onCancel: () {",
			"    },",
			"    onConfirm: () {",
			"      Get.back(result: true);",
			"    }",
			"  );",
			"  if (data != null && data) {",
			"    EasyLoading.show(status: 'Saving...');",
			"    await ${2:UserService}().${3:updateDisplayName}(",
			"      formKey.currentState!.value['${4:edit_display_name}']",
			"    );",
			"    EasyLoading.dismiss();",
			"    Get.back();",
			"  }",
			"}"
		],
		"description": "create function validation of form builder with dialog confirmation",
	},
	"Firebase Collection": {
		"prefix": "dw create collection firebase",
		"body": [
			"import 'package:cloud_firestore/cloud_firestore.dart';",
			"import './firebase_collection.dart';\t",
			"class ${1:Name}Collection {",
			"\tstatic const String collectionName = \"${2:Name}\";",
			"\tCollectionReference<${3:NameModel}> collectionRef;",
			"\t${1:Name}Collection._(this.collectionRef);",
			"",
			"\tstatic ${1:Name}Collection create() {",
			"\t\tfinal CollectionReference<${3:NameModel}> collection =",
			"\t\t\tFirebaseCollection.getOrCreateCollection<${3:NameModel}>(",
			"\t\t\tcollectionName: collectionName,",
			"\t\t\tfromJson: ${3:NameModel}.fromFirestore,",
			"\t\t\ttoJson: (${3:NameModel} model) => model.toJson(),",
			"\t\t);",
			"\t\treturn ${1:Name}Collection._(collection);",
			"\t}",
			"}"
		],
		"description": "Creates a new NameCollection class"
	},
	"obx ini": {
		"prefix": "dw obx init",
		"body": [
			"try {",
			"\t${1:listVariable} = await ${2:ServiceName}Service().${3:methodName}(${4:parameter});",
			"\tif (${1:listVariable}.isNotEmpty) {",
			"\t\t\t\tchange(${1:listVariable}, status: RxStatus.success());",
			"\t} else {",
			"\t\t\tchange([], status: RxStatus.empty());",
			"\t}",
			"} catch (e) {",
			"  change([], status: RxStatus.error(e.toString()));",
			"}"
		],
		"description": "create init obx data from service"
	},
	"Get Dynamic Prescription List": {
		"prefix": "dw future function get list",
		"body": [
			"Future<List<${1:DataModel}>> ${2:functionName}() async {",
			"  try {",
			"    var ${3:listName}Ref = await FirebaseCollection().${4:collectionName}.where('id', isEqualTo: '').get();",
			"    List<${1:DataModel}> ${3:listName}= ${3:listName}Ref.docs.map((e) => e.data()).toList();",
			"",
			"    return ${3:listName};",
			"} on FirebaseException catch (e) {",
			"return Future.error(e.message ?? e.toString());",
			"}",
			"catch (e) {",
			"    return Future.error(e);",
			"  }",
			"}"
		],
		"description": "Create function that add data from firebase "
	},
	"Future function to add data": {
		"prefix": "dw future function add data",
		"body": [
			"Future<${2:DataType}> ${1:functionName}(${2:DataType} ${3:dataObject}) async {",
			"  try {",
			"   var ${3:dataObject}Ref = await FirebaseCollection().${4:collectionName}.add(${3:dataObject});",
			"${2:DataType} new${3:dataObject}WithId = ",
			"  ${3:dataObject}.copyWith(id: ${3:dataObject}Ref.id);",
			" return new${3:dataObject}WithId;",
			"  } on FirebaseException catch (e) {",
			"    return Future.error(e.message ?? e.toString());",
			"  } catch (e) {",
			"    return Future.error(e);",
			"  }",
			"}"
		],
		"description": "Future function to add a new data to the database"
	},
	"Future function update data": {
		"prefix": "dw future function update data",
		"body": [
			"Future<void> ${1:updateFunctionName}(${2:DataType} ${3:parameter}) async {",
			"  try {",
			"    await FirebaseCollection()",
			"        .${4:collectionName}",
			"        .doc(${3:parameter}.id)",
			"        .update(${3:parameter}.toJson());",
			"  } on FirebaseException catch (e) {",
			"    return Future.error(e.message ?? e.toString());",
			"  } catch (e) {",
			"    return Future.error(e);",
			"  }",
			"}"
		],
		"description": "function to update firebase data"
	},
	"Confirmation Dialog": {
		"prefix": "dw default dialog confirm",
		"body": [
			"var isConfirm = await Get.defaultDialog<bool>(",
			"  title: 'Confirmation',",
			"  middleText: 'Confirm Message'.tr,",
			"  textCancel: 'Cancel',",
			"  textConfirm: 'OK',",
			"  onCancel: () {},",
			"  onConfirm: () {",
			"    Get.back(result: true);",
			"  }",
			");",
			"if (isConfirm != null && isConfirm) {",
			"  EasyLoading.show(status: 'Saving...');",
			"  /// Start the operation",
			"  EasyLoading.dismiss();",
			"}"
		],
		"description": "Show a confirmation dialog and perform an action based on the result"
	},
	"Future function delete data firebase": {
		"prefix": "dw future function delete data",
		"body": [
			"Future ${1:deleteFunctionName}(String ${2:prescriptionId}) async {",
			"  try {",
			"    await FirebaseCollection().${3:firebaseCollection}.doc(${2:prescriptionId}).delete();",
			"  } on FirebaseException catch (e) {",
			"    return Future.error(e.message ?? e.toString());",
			"  } catch (e) {",
			"    return Future.error(e);",
			"  }",
			"}"
		],
		"description": "Delete data from firebase from the database"
	},
	"Create data table": {
		"prefix": "dw create data table source",
		"body": [
			"import 'package:flutter/material.dart';",
			"",
			"class ${1:}DataSource extends DataTableSource {",
			"\tlate final List<${1:}Model> list${1:};",
			"",
			"\t${1:}DataSource(this.list${1:});",
			"",
			"\t@override",
			"\tDataRow? getRow(int index) {",
			"\t\treturn DataRow(cells: [",
			"\t\t\tDataCell(Text(list${1:}[index].displayName ?? '')),",
			"\t\t\tDataCell(Text(list${1:}[index].email ?? '')),",
			"\t\t\tDataCell(Text(TimeFormat().formatDate(list${1:}[index].createdAt).toString())),",
			"\t\t\tDataCell(Text(list${1:}[index].role.toString())),",
			"\t\t\tDataCell(",
			"\t\t\t\tIconButton(",
			"\t\t\t\t\ticon: Icon(Icons.delete),",
			"\t\t\t\t\tonPressed: () {},",
			"\t\t\t\t),",
			"\t\t\t)",
			"\t\t]);",
			"\t}",
			"",
			"\t@override",
			"\tbool get isRowCountApproximate => false;",
			"",
			"\t@override",
			"\tint get rowCount => list${1:}.length;",
			"",
			"\t@override",
			"\tint get selectedRowCount => 0;",
			"}"
		],
		"description": "Creates a DataTableSource class for managing table"
	},
	"Group with Setup, TearDown, and Test": {
		"prefix": "dw test group",
		"body": [
			"group('Test Group', () {",
			"  setUp(() {",
			"    // Set up the initial state",
			"  });",
			"",
			"  tearDown(() {",
			"    // Clean up any resources",
			"  });",
			"",
			"  test('Test Case 1', () {",
			"    // Test case implementation",
			"  });",
			"});"
		],
		"description": "Test group with setup, tearDown, and a test case"
	},
	"Generate code for Calling function": {
		"prefix": "dw future function https callable",
		"body": [
			"Future ${1:functionName}() async {",
			"try {",
			"final HttpsCallable callable = FirebaseFunctions.instance.httpsCallable('${2:cloudFunctionName}');",
			"final HttpsCallableResult result = await callable.call({",
			"  '${3:parameter1}': ${3:parameter1},",
			"});",
			"",
			"final data = result.data;",
			"if (data is Map<String, dynamic> && data.containsKey('token')) {",
			"  return data['token'];",
			"} else {",
			"  throw Exception('Invalid response');",
			"}",
			"} catch (e) {",
			"  return Future.error(e);",
			"}",
			"}",
		],
		"description": "Generate https callabe function"
	},
	"Generate Service File with Getx": {
		"prefix": "dw service getx firebase",
		"body": [
			"import 'package:get/get.dart';",
			"import '../firebase_collection/firebase_collection.dart';",
			"class ${1:Service}Service extends GetxService {",
			"  static late FirebaseCollection _firebaseCollection;",
			"  ${1:Service}Service init(FirebaseCollection firebaseCollection) {",
			"     _firebaseCollection = firebaseCollection;",
			"    return this;",
			"  }",
			"",
			"}",
		],
		"description": "Generate https callabe function"
	},
	"Flutter DataTable2 Snippet": {
		"prefix": "dw data table 2 list",
		"body": [
			"return SizedBox(",
			"    height: 720,",
			"    child: DataTable2(",
			"        columnSpacing: 12,",
			"        horizontalMargin: 12,",
			"        minWidth: 600,",
			"        columns: const [",
			"            DataColumn2(",
			"                label: Text('Category Name'),",
			"                size: ColumnSize.L,",
			"            ),",
			"            DataColumn(",
			"                label: Text('Action'),",
			"            ),",
			"        ],",
			"        rows: List<DataRow>.generate(",
			"            ${1:list}!.length,",
			"            (index) => DataRow(",
			"                cells: [",
			"                    DataCell(Text(${1:list}[index].${2:name}!)),",
			"                    DataCell(",
			"                        IconButton(",
			"                            icon: const Icon(Icons.file_open),",
			"                            onPressed: () {",
			"                                Get.toNamed(",
			"                                    '${Routes.QUESTIONS}?categoryId=${${1:list}[index].id!}',",
			"                                    arguments: [${1:list}[index]]);",
			"                            },",
			"                        ),",
			"                    )",
			"                ],",
			"            ),",
			"        ),",
			"    ),",
			");"
		],
		"description": "Flutter DataTable2 Snippet"
	},
	"Get Document": {
		"prefix": "dw future function get document",
		"body": [
			"Future<${1:DocumentModel}?> ${2:getDocumentById}(String documentId) async {",
			"  try {",
			"    var ${4:document} = await FirebaseCollection().${3:documentCol}.doc(documentId).get();",
			"    if (${4:document}.exists) {",
			"      ${1:DocumentModel} data = ${4:document}.data()!;",
			"",
			"      return data;",
			"    } else {",
			"      return null;",
			"    }",
			"  } on FirebaseException catch (e) {",
			"    return Future.error(e.message ?? e.toString());",
			"  } catch (e) {",
			"    return Future.error(e);",
			"  }",
			"}"
		],
		"description": "Async function to get a document from Firebase based on its ID"
	},
	"FormBuilder": {
		"prefix": "dw form builder",
		"body": [
			"FormBuilder(",
			"    autovalidateMode: AutovalidateMode.onUserInteraction,",
			"    key: controller.loginFormKey,",
			"    child: Column(",
			"        children: [",
			"            FormBuilderTextField(",
			"                key: Key('username'),",
			"                name: controller.username,",
			"                textInputAction: TextInputAction.next,",
			"                validator: FormBuilderValidators.compose([",
			"FormBuilderValidators.required(),",
			"FormBuilderValidators.email()",
			"]),",
			"                decoration: InputDecoration(",
			"                    hintText: 'Email',",
			"                    border: OutlineInputBorder(",
			"                        borderRadius: BorderRadius.circular(10.0),",
			"                        borderSide: BorderSide(",
			"                            width: 0,",
			"                            style: BorderStyle.none,",
			"                        )",
			"                    ),",
			"                    fillColor: Colors.grey[200],",
			"                    filled: true",
			"                ),",
			"            ),",
			"        ],",
			"    ),",
			")"
		],
		"description": "FormBuilder snippet",
	},
	"Form Key": {
		"prefix": "dw form key",
		"body": [
			"var formKey = GlobalKey<FormBuilderState>();"
		],
		"description": "FormBuilder formkey",
	},
	"class singletone": {
		"prefix": "dw class singletone",
		"body": [
			"class ${1:ClassName} {",
			"  static final ${1:ClassName} _instance = ${1:ClassName}._internal();",
			"  factory ${1:ClassName}() => _instance;",
			"  ${1:ClassName}._internal();",
			"  // Add your class properties and methods here",
			"}"
		],
		"description": "class singletone"
	},
	"App Write Create Document": {
		"prefix": "dw appwrite create document",
		"body": [
			"await databases.createDocument(",
			"      databaseId: databaseId,",
			"      collectionId: ${1:collectionId},",
			"      documentId: ID.unique(),",
			"      data: ${2:data},",
			"    );"
		],
		"description": "create document"
	},
	"AppWrite image url": {
		"prefix": "dw appwrite image url",
		"body": " final appwriteImageUrl ='https://cloud.appwrite.io/v1/storage/buckets/$bucketId/files/${uploadResult.$id}/view?project=${1:YOUR APPWRITE PROJECT ID}';",
		"description": "appwrite image url"
	},
	"Singletone class": {
		"prefix": "dw class singletone",
		"body": [
			"class ${1:ClassName} {",
			"  static final ${1:ClassName} _instance = ${1:ClassName}._internal();",
			"  factory ${1:ClassName}() {",
			"    return _instance;",
			"  }",
			"  ${1:ClassName}._internal();",
			"}"
		],
		"description": "Dart singleton pattern with adjustable class name"
	}
}