{"id":13553758,"url":"https://github.com/andrasferenczi/dart-data-plugin","last_synced_at":"2025-04-03T05:31:32.077Z","repository":{"id":38838008,"uuid":"185741764","full_name":"andrasferenczi/dart-data-plugin","owner":"andrasferenczi","description":"IDEA plugin for generating utility methods for Dart data classes","archived":false,"fork":false,"pushed_at":"2024-06-28T03:54:14.000Z","size":2242,"stargazers_count":147,"open_issues_count":12,"forks_count":31,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-11-04T01:32:52.737Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andrasferenczi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-09T06:43:33.000Z","updated_at":"2024-08-29T01:33:11.000Z","dependencies_parsed_at":"2024-11-04T01:31:12.473Z","dependency_job_id":"7cbf37da-5953-4799-a550-ebd83450ff41","html_url":"https://github.com/andrasferenczi/dart-data-plugin","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrasferenczi%2Fdart-data-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrasferenczi%2Fdart-data-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrasferenczi%2Fdart-data-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andrasferenczi%2Fdart-data-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andrasferenczi","download_url":"https://codeload.github.com/andrasferenczi/dart-data-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246944377,"owners_count":20858773,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T12:02:32.645Z","updated_at":"2025-04-03T05:31:28.301Z","avatar_url":"https://github.com/andrasferenczi.png","language":"Kotlin","funding_links":[],"categories":["Kotlin"],"sub_categories":[],"readme":"# Dart Data Class Plugin\n\n![Usage](img/dart-data-usage.gif)\n\nThis plugin is created for those who would like to have extra data manipulation methods in their data classes without having to write boilerplate code.\n\n![ScreenShot](img/generate-menu.png)\n\nThis plugin can generate the following code:\n- Named Argument Constructor\n- `copyWith`: copies the instance and overrides the given parameters\n- `toMap`: converts your class into a map of `Map\u003cString, dynamic\u003e`\n- `fromMap`: constructs your class from a `Map\u003cString, dynamic\u003e` using the named argument constructor\n- all of the above with `toString`, `equals` (`==` operator), `hashcode`\n\n## Example\n\nLet's say you have a class called `Person` with the properties:\n\n```dart\nclass Person {\n  final int id;\n  final String _firstName, _lastName;\n  final int age;\n  int? income;\n\n  String get name =\u003e _firstName + \" \" + _lastName;\n}\n```\n\nUsing all generators of this plugin and selecting all properties, this class will look like the following. \n\n*(Note that some features of this generation can be customized, see details below.)*\n\n\n```dart\nclass Person {\n  final int id;\n  final String _firstName, _lastName;\n  final int age;\n  int? income;\n\n  String get name =\u003e _firstName + \" \" + _lastName;\n\n//\u003ceditor-fold desc=\"Data Methods\"\u003e\n\n  Person({\n    required this.id,\n    required this.age,\n    this.income,\n    required String firstName,\n    required String lastName,\n  })  : _firstName = firstName,\n        _lastName = lastName;\n\n  @override\n  bool operator ==(Object other) =\u003e\n      identical(this, other) ||\n      (other is Person \u0026\u0026\n          runtimeType == other.runtimeType \u0026\u0026\n          id == other.id \u0026\u0026\n          _firstName == other._firstName \u0026\u0026\n          _lastName == other._lastName \u0026\u0026\n          age == other.age \u0026\u0026\n          income == other.income);\n\n  @override\n  int get hashCode =\u003e\n      id.hashCode ^\n      _firstName.hashCode ^\n      _lastName.hashCode ^\n      age.hashCode ^\n      income.hashCode;\n\n  @override\n  String toString() {\n    return 'Person{' +\n        ' id: $id,' +\n        ' _firstName: $_firstName,' +\n        ' _lastName: $_lastName,' +\n        ' age: $age,' +\n        ' income: $income,' +\n        '}';\n  }\n\n  Person copyWith({\n    int? id,\n    String? firstName,\n    String? lastName,\n    int? age,\n    int? income,\n  }) {\n    return Person(\n      id: id ?? this.id,\n      firstName: firstName ?? this._firstName,\n      lastName: lastName ?? this._lastName,\n      age: age ?? this.age,\n      income: income ?? this.income,\n    );\n  }\n\n  Map\u003cString, dynamic\u003e toMap() {\n    return {\n      'id': this.id,\n      '_firstName': this._firstName,\n      '_lastName': this._lastName,\n      'age': this.age,\n      'income': this.income,\n    };\n  }\n\n  factory Person.fromMap(Map\u003cString, dynamic\u003e map) {\n    return Person(\n      id: map['id'] as int,\n      firstName: map['_firstName'] as String,\n      lastName: map['_lastName'] as String,\n      age: map['age'] as int,\n      income: map['income'] as int?,\n    );\n  }\n\n//\u003c/editor-fold\u003e\n}\n```\n\n## Settings\n\n![ScreenShot](img/settings-menu.png)\n\nYou can find additional settings under `Settings` \u003e `Editor` \u003e `Dart Data Class Plugin` where you have the following customization options:\n\n- set the name of the copy method\n- use `@required` annotation\n- use `new` keyword when instantiation\n- use the `const` keyword for the constructor generation - all fields in the class have to be final\n- copy function can be specified to return the same instance. This Option has the same requirement as the const keyword. Useful when using Dart in a Redux architecture.\n- key mapper for `toMap` and `fromMap` - use your own logic to transform the keys to their original values - useful when database result returns prefixed or uppercased result\n\n\n#### Under the hood\n\nThis project is built using Kotlin and makes use of IntelliJ's PSI elements for extracting the structure of the Dart file of your selection.\n\n### Known issues\n\n- If the class ends with a single-line comment, code is generated from an invalid location\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrasferenczi%2Fdart-data-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandrasferenczi%2Fdart-data-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandrasferenczi%2Fdart-data-plugin/lists"}