{"id":15134034,"url":"https://github.com/swedesjs/vkdart","last_synced_at":"2025-07-11T18:06:49.468Z","repository":{"id":61281669,"uuid":"550098241","full_name":"swedesjs/vkdart","owner":"swedesjs","description":"Package helps simplify working with the VK API. Completely wraps VK methods, has event support and much more.","archived":false,"fork":false,"pushed_at":"2024-04-05T20:15:01.000Z","size":660,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-06T15:53:44.325Z","etag":null,"topics":["api","dart","dart-library","dart-package","vk","vk-api","vk-callback-api","vk-longpoll","vk-sdk","vkontakte","vkontakte-api"],"latest_commit_sha":null,"homepage":"https://pub.dev/packages/vkdart","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/swedesjs.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}},"created_at":"2022-10-12T07:48:08.000Z","updated_at":"2024-07-29T06:17:26.000Z","dependencies_parsed_at":"2024-04-05T21:23:54.642Z","dependency_job_id":"9e0abaee-39d5-4f3b-a94f-9dd3e8d5137b","html_url":"https://github.com/swedesjs/vkdart","commit_stats":{"total_commits":19,"total_committers":1,"mean_commits":19.0,"dds":0.0,"last_synced_commit":"6e6be714a5db7ae4e02b853a61663de2d8745f75"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/swedesjs/vkdart","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swedesjs%2Fvkdart","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swedesjs%2Fvkdart/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swedesjs%2Fvkdart/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swedesjs%2Fvkdart/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swedesjs","download_url":"https://codeload.github.com/swedesjs/vkdart/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swedesjs%2Fvkdart/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264868616,"owners_count":23676091,"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":["api","dart","dart-library","dart-package","vk","vk-api","vk-callback-api","vk-longpoll","vk-sdk","vkontakte","vkontakte-api"],"created_at":"2024-09-26T05:02:09.028Z","updated_at":"2025-07-11T18:06:49.423Z","avatar_url":"https://github.com/swedesjs.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- @formatter:off --\u003e\n# VkDart\n\n[![Pub Version](https://img.shields.io/pub/v/vkdart?style=flat-square)](https://pub.dev/packages/vkdart)\n[![Pub Popularity](https://img.shields.io/pub/popularity/vkdart?style=flat-square)](https://pub.dev/packages/vkdart)\n[![Pub Points](https://img.shields.io/pub/points/vkdart?style=flat-square)](https://pub.dev/packages/vkdart)\n\n\u003e The package helps to simplify the work with [VK API](https://dev.vk.com/).\n\u003e\n\u003e A chat room to discuss how the package works - https://t.me/vk_dart\n\n## Features\n1. **Reliability.** Package functionality is wrapped in unit tests. \n2. **Supports events.** Supports Callback API, Longpoll API\n3. **Development.** Functionality is becoming more and more every day!\n4. **Easy to use.** Very easy to use!\n5. **Model support.** There is a description of event, attachment and object models.\n\n## Usage\n\nInitialization:\n```dart\nimport 'package:vkdart/vkdart.dart';\n\nvoid main() async {\n  final TOKEN = '';\n  final GROUP_ID = 1;\n\n  final myFetcher = Longpoll(GROUP_ID); // or Webhook (CallbackAPI).\n  final vkdart = VkDart(TOKEN, fetcher: myFetcher);\n\n  vkdart.start();\n}\n```\n\nUsing API:\n```dart\nawait vkdart.request('groups.getById', {'group_id': 1}); // List\u003cMap\u003cString, dynamic\u003e\u003e\n```\n\n## Events\n[VkDart](https://pub.dev/documentation/vkdart/latest/vkdart/VkDart-class.html) base class contains functions for processing VK API events.\nSome events are combined into a single handler, consider this example: \n```dart\n/// message_new, message_reply, message_reply.\nvkdart.onMessage().listen((event) { ... });\n```\n\nIn this case the events message_new, message_reply, message_edit will be processed in this listen. \nIn order to filter the necessary events, you can modify [Stream](https://www.dartlang.org/tutorials/language/streams#methods-that-modify-a-stream): \n```dart\nvkdart\n        .onMessage()\n        .where((event) =\u003e event.isNew \u0026\u0026 event.isChat)\n        .listen((event) { ... });\n```\n\nDue to the fact that VK API is also updated, new events are added, there is a handler [onUnsupportedEvent](https://pub.dev/documentation/vkdart/latest/vkdart/VkDart/onUnsupportedEvent.html).\nIf you have caught such an event, please report it to our [chat](https://t.me/vk_dart).\n```dart\nvkdart.onUnsupportedEvent().listen((event) {\n    print(\n      'An unsupported event has arrived!\\n'\n      'It is necessary to inform the chat https://t.me/vk_dart\\n\\n'\n      'Type of event ${event.eventType}\\n'\n      'Event Object: ${event.object}',\n    );\n});\n```\n\n\u003e Each event handler, has its own functions, fields and other useful features. All update models can be found on this [page](https://pub.dev/documentation/vkdart/latest/vkdart.model/vkdart.model-library.html). \n\u003e \n\u003e All event handlers can be found on this [page](https://pub.dev/documentation/vkdart/latest/vkdart/VkDart-class.html). \n\n## Keyboard\nThe package includes a [keyboard builder](https://pub.dev/documentation/vkdart/latest/vkdart.util/VkDartKeyboard-class.html):\n```dart\nimport 'package:vkdart/util.dart' show VkDartKeyboard, VkDartKeyboardColor;\n\nfinal keyboard = VkDartKeyboard(\n    oneTime: true, // default value\n    inline: false // default value\n);\n```\n\n\u003e Warning!\n\u003e The keyboard grid has limitations:\n\u003e - For conventional keyboard size: 5 × 10, maximum number of keys: 40\n\u003e - For inline keyboard size: 5 × 6, maximum number of keys: 10\n\nText button:\n```dart\nkeyboard.addButtonText('Hello world!', color: VkDartKeyboardColor.primary, payload: {'button': 'text'});\n```\n\u003e The payload will be available in [message_new](https://pub.dev/documentation/vkdart/latest/vkdart/VkDart/onMessage.html) event, in the [messagePayload](https://pub.dev/documentation/vkdart/latest/vkdart.vkontakte/MessageModel/messagePayload.html) property. \n\nURL button:\n```dart\nkeyboard.addButtonLink('mysite.com', 'My Site');\n```\n\nLocation button:\n```dart\nkeyboard.addButtonLocation(payload: {'button': 'location'});\n```\n\u003e The payload will be available in [message_new](https://pub.dev/documentation/vkdart/latest/vkdart/VkDart/onMessage.html) event, in the [messagePayload](https://pub.dev/documentation/vkdart/latest/vkdart.vkontakte/MessageModel/messagePayload.html) property. \n\nVk Pay button: \n```dart\nkeyboard.addButtonVkPay(\"action=transfer-to-group\u0026group_id=1\u0026aid=10\");\n```\n\nOpen APP button:\n```dart\nkeyboard.addButtonApp(6232540, -157525928, hash: \"123\", appName: 'LiveWidget');\n```\n\nCallback button:\n```dart\nkeyboard.addButtonCallback(\n    'Hello world!', \n    color: VkDartKeyboard.secondary, // default value\n    payload: {'button': 'callback'}\n);\n```\n\u003e The payload will be available in the [message_event](https://pub.dev/documentation/vkdart/latest/vkdart/VkDart/onMessageEvent.html) event, in the [eventPayload](https://pub.dev/documentation/vkdart/latest/vkdart.model/VkDartMessageEventUpdate/eventPayload.html) property. \n\nMove on to the next row:\n```dart\nkeyboard\n  ..addButtonText('1 row: Hello world!')\n  ..nextRow()\n  ..addButtonText('2 row: Hello world!');\n```\n\nUsage in the [messages.send](https://pub.dev/documentation/vkdart/latest/vkdart.vkontakte/Messages/send.html) method:\n```dart\nvkdart.messages.send({\n    'peer_id': PEER_ID,\n    'message': 'Hello world!',\n    'random_id': RANDOM_ID,\n    'keyboard': keyboard.toJson()\n});\n```\n\nButton Colors:\n| Field                         | Description                  | Color |\n| ----------------------------- | ---------------------------- | ----- |\n| VkDartKeyboardColor.primary   | Main Action                  | Blue  |\n| VkDartKeyboardColor.secondary | It's just a button           | White |\n| VkDartKeyboardColor.negative  | Dangerous Action or Failure  | Red   |\n| VkDartKeyboardColor.positive  | \"Agree,\" \"Confirm.\"          | Green |\n\n## Attachments\nThere are two types of class:\n- [AttachmentModel](https://pub.dev/documentation/vkdart/latest/vkdart.vkontakte/CustomAttachmentModel-class.html) - A base class on which all attachments (and those that can be attached) depend, which cannot be attached.\n  - [GiftAttachmentModel](https://pub.dev/documentation/vkdart/latest/vkdart.vkontakte/GiftAttachmentModel-class.html)\n  - [LinkAttachmentModel](https://pub.dev/documentation/vkdart/latest/vkdart.vkontakte/LinkAttachmentModel-class.html)\n  - [StickerAttachmentModel](https://pub.dev/documentation/vkdart/latest/vkdart.vkontakte/StickerAttachmentModel-class.html)\n- [CustomAttachmentModel](https://pub.dev/documentation/vkdart/latest/vkdart.vkontakte/CustomAttachmentModel-class.html) - Attachment class that can be attached `{attachment_type}{owner_id}_{attach_id}_{?access_key?}`.\n  - [PhotoAttachmentModel](https://pub.dev/documentation/vkdart/latest/vkdart.vkontakte/PhotoAttachmentModel-class.html)\n  - [AudioAttachmentModel](https://pub.dev/documentation/vkdart/latest/vkdart.vkontakte/AudioAttachmentModel-class.html)\n  - [DocumentAttachmentModel](https://pub.dev/documentation/vkdart/latest/vkdart.vkontakte/DocumentAttachmentModel-class.html)\n  - [GraffitiAttachmentModel](https://pub.dev/documentation/vkdart/latest/vkdart.vkontakte/GraffitiAttachmentModel-class.html)\n  - [MarketAlbumAttachmentModel](https://pub.dev/documentation/vkdart/latest/vkdart.vkontakte/MarketAlbumAttachmentModel-class.html)\n  - [MarketAttachmentModel](https://pub.dev/documentation/vkdart/latest/vkdart.vkontakte/MarketAttachmentModel-class.html)\n  - [NoteAttachmentModel](https://pub.dev/documentation/vkdart/latest/vkdart.vkontakte/NoteAttachmentModel-class.html)\n  - [PollAttachmentModel](https://pub.dev/documentation/vkdart/latest/vkdart.vkontakte/PollAttachmentModel-class.html)\n  - [VideoAttachmentModel](https://pub.dev/documentation/vkdart/latest/vkdart.vkontakte/VideoAttachmentModel-class.html)\n  - [WallAttachmentModel](https://pub.dev/documentation/vkdart/latest/vkdart.vkontakte/WallAttachmentModel-class.html)\n  - [WallReplyAttachmentModel](https://pub.dev/documentation/vkdart/latest/vkdart.vkontakte/WallReplyAttachmentModel-class.html)\n  - [WikiPageAttachmentModel](https://pub.dev/documentation/vkdart/latest/vkdart.vkontakte/WikiPageAttachmentModel-class.html)\n\n```dart\nfinal customAttachment = CustomAttachmentModel({\n    'owner_id': 1,\n    'id': 2,\n    // 'access_key': 'ACCESS_KEY'\n}, attachType: 'photo'); \n```\n\nIn VK there is a format of attachments, let's say to send it in private messages, for convenience the `CustomAttachmentModel` class has an overridden function `toString()`, which will return this format.\n```dart\ncustomAttachment.toString(); // photo1_2 and photo1_2_ACCESS_KEY (if access != null)\n[customAttachment, customAttachment].join(',') // photo1_2,photo1_2\n```\n\nSuppose we have an attachment object in Map format, in order to convert it into the necessary model, we will use the [`fromSpecificModel`](https://pub.dev/documentation/vkdart/latest/vkdart.vkontakte/AttachmentModel/AttachmentModel.fromSpecificModel.html) constructor:\n```dart\nAttachmentModel.fromSpecificModel({\n    'owner_id': 1,\n    'id': 2\n}, attachType: 'photo'); // PhotoAttachmentModel\n```\n\nConvert the attachment string to a model: \n```dart\nCustomAttachment.fromString('photo1_2'); // PhotoAttachmentModel\n```\n\n## Future plans\n- Release models of VK API objects. ✔\n- Release a class that makes keyboarding easier. ✔\n- Release features, for chatbot commands.\n\n## Bugs and feature requests\n\nPlease send a bug report to [issue tracker](https://github.com/swedesjs/vkdart/issues)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswedesjs%2Fvkdart","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswedesjs%2Fvkdart","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswedesjs%2Fvkdart/lists"}