{"id":15496265,"url":"https://github.com/s0punk/flutter_fit_utils","last_synced_at":"2025-04-10T20:21:33.579Z","repository":{"id":240819131,"uuid":"802613792","full_name":"s0punk/flutter_fit_utils","owner":"s0punk","description":"A flutter package to easily manage data in and out of repositories. This package is the core of it's environement.","archived":false,"fork":false,"pushed_at":"2024-12-24T16:52:59.000Z","size":352,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-31T13:03:47.131Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/flutter_fit_utils","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/s0punk.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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":"2024-05-18T19:32:06.000Z","updated_at":"2024-12-27T09:57:01.000Z","dependencies_parsed_at":"2024-05-28T18:18:35.249Z","dependency_job_id":"4c11f7dc-37be-4806-9b56-0b55bb25a0bf","html_url":"https://github.com/s0punk/flutter_fit_utils","commit_stats":{"total_commits":45,"total_committers":2,"mean_commits":22.5,"dds":0.4222222222222223,"last_synced_commit":"7a6366fe8cab966db3f95e334af213fcdde6268f"},"previous_names":["s0punk/flutter_fit_utils"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s0punk%2Fflutter_fit_utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s0punk%2Fflutter_fit_utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s0punk%2Fflutter_fit_utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s0punk%2Fflutter_fit_utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/s0punk","download_url":"https://codeload.github.com/s0punk/flutter_fit_utils/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248289910,"owners_count":21078922,"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-10-02T08:24:10.737Z","updated_at":"2025-04-10T20:21:33.559Z","avatar_url":"https://github.com/s0punk.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"A flutter package to easily manage data in and out of repositories.\nThis package is the core of it's environement. To know about other packages related to flutter_fit_utils, see the diagram below.\n\n![flutter_fit_utils drawio](https://github.com/s0punk/flutter_fit_utils_provider/assets/59456672/74b056f7-f85d-4635-891c-fd9feee99cfb)\n\n## Features\n\nUse this package to:\n- Get a uniform way of reading and writing data with Models.\n- Create a repository and a service for your data with a single line of code.\n- Get access to extensions for multiple flutter base classes.\n\nHere are the supported repositories:\n- Firebase Firestore\n- Hive\n- Firebase Remote Config (Read Only)\n- shared_preferences\n- Firebase Storage (soon)\n\n## Getting started\n\n- Go inside your pubspec.yaml file\n- Add this line under the dependencies:\n```\nflutter_fit_utils: ^2.0.0\n```\n- Get dependencies\n```\nflutter pub get\n```\n\n## Usage\n\n### Creating a model\nMake a class Modelable so it can be managed by a service and sent to a repository. For example:\n```dart\nimport 'package:flutter_fit_utils/flutter_fit_utils.dart';\n\n/// Example user class.\nclass User extends Modelable {\n  static const String _nameKey = \"name\";\n\n  /// User's last name.\n  final String name;\n\n  /// Creates a new user.\n  const User({this.name = \"\", super.id, super.userId});\n\n  /// Creates an invalid user.\n  const User.invalid() : name = \"\", super.invalid();\n\n  /// Creates a user from a [Model].\n  User.fromModel(super.model) :\n    name = model.data[_nameKey].toString(),\n    super.fromModel();\n\n  @override\n  User copyWith({String? id, String? userId, bool? invalid, String? name}) =\u003e User(\n    name: name ?? this.name,\n    id: id ?? this.id,\n    userId: userId ?? this.userId,\n  );\n\n  @override\n  Model toModel() =\u003e Model(\n    id: id,\n    userId: userId,\n    data: {\n      _nameKey: name,\n    },\n  );\n}\n```\n\nIf creating an entire class is too much for your use case, this package offers extensions to convert primitive types to Models:\n```dart\nfinal int myValue = 1;\n\n/// Write.\nfinal Model model = myValue.toModel();\n\n/// Read.\nfinal int otherValue = intFromModel(model);\n```\n\nHere are the supported types:\n- int\n- double\n- num\n- bool\n- String\n- List (Of Modelable objects)\n- Map\u003cString, dynamic\u003e\n\n### Managing your model with a service\nYou can create a service for your model with a single line of code:\n```dart\nimport 'package:flutter_fit_utils/flutter_fit_utils.dart';\n\nfinal Service\u003cUser\u003e service = FirestoreService(\"my_user_collection\", User.fromModel);\n```\n\nThis example automatically uses a FirestoreCollection repository. In the case of FirestoreCollection, the only thing you have to do\nis go to your Firebase project, and create a new collection \"my_user_collection\" in your database.\n\nIf you want more control over your service, you can also create a custom one:\n```dart\nimport 'package:flutter_fit_utils/flutter_fit_utils.dart';\n\nfinal class CustomUserService extends Service\u003cUser\u003e {\n  CustomUserService(super.repositoryId, super.fromModelFactory) {\n    repository = FirestoreCollection(collectionId: repositoryId);\n  }\n\n  @override\n  Future\u003cList\u003cUserData\u003e\u003e getAll({String? userId, Where? where, String? orderBy, bool descending = true}) async {\n    // Implement your custom logic...\n  }\n}\n```\n\nNote that you can override any function of the base Service class.\n\n## Additional information\n\nFeel free to [give any feedback](https://github.com/s0punk/flutter_fit_utils/issues) ! This package is also open to contributions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs0punk%2Fflutter_fit_utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fs0punk%2Fflutter_fit_utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs0punk%2Fflutter_fit_utils/lists"}