{"id":15177615,"url":"https://github.com/buijs-dev/klutter-dart","last_synced_at":"2025-08-16T10:35:11.363Z","repository":{"id":39911731,"uuid":"494559244","full_name":"buijs-dev/klutter-dart","owner":"buijs-dev","description":"Klutter plugin makes it possible to write a Flutter plugin for both Android and iOS using Kotlin only.","archived":false,"fork":false,"pushed_at":"2024-05-24T17:33:11.000Z","size":6037,"stargazers_count":78,"open_issues_count":2,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-01-31T21:11:28.916Z","etag":null,"topics":["android","dart","flutter","flutter-plugin","ios","kotlin","kotlinmultiplatform"],"latest_commit_sha":null,"homepage":"","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/buijs-dev.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":["buijs-dev"]}},"created_at":"2022-05-20T17:51:38.000Z","updated_at":"2025-01-30T07:06:47.000Z","dependencies_parsed_at":"2024-03-21T18:48:17.270Z","dependency_job_id":"4ecdf5bd-1e96-4ca1-ac5b-8cd032f2723c","html_url":"https://github.com/buijs-dev/klutter-dart","commit_stats":{"total_commits":140,"total_committers":2,"mean_commits":70.0,"dds":0.09285714285714286,"last_synced_commit":"d55440838045406f2653058ea4694beece05bad3"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buijs-dev%2Fklutter-dart","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buijs-dev%2Fklutter-dart/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buijs-dev%2Fklutter-dart/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/buijs-dev%2Fklutter-dart/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/buijs-dev","download_url":"https://codeload.github.com/buijs-dev/klutter-dart/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238366720,"owners_count":19460172,"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":["android","dart","flutter","flutter-plugin","ios","kotlin","kotlinmultiplatform"],"created_at":"2024-09-27T14:41:19.261Z","updated_at":"2025-02-11T20:31:37.372Z","avatar_url":"https://github.com/buijs-dev.png","language":"Dart","funding_links":["https://github.com/sponsors/buijs-dev"],"categories":[],"sub_categories":[],"readme":"[![](https://img.shields.io/badge/Buijs-Software-blue)](https://pub.dev/publishers/buijs.dev/packages)\n[![GitHub license](https://img.shields.io/github/license/buijs-dev/klutter-dart?color=black\u0026logoColor=black)](https://github.com/buijs-dev/klutter-dart/blob/main/LICENSE)\n[![pub](https://img.shields.io/pub/v/klutter)](https://pub.dev/packages/klutter)\n[![codecov](https://img.shields.io/codecov/c/github/buijs-dev/klutter-dart?logo=codecov)](https://codecov.io/gh/buijs-dev/klutter-dart)\n[![CodeScene Code Health](https://codescene.io/projects/27237/status-badges/code-health)](https://codescene.io/projects/27237)\n\n\n\u003cbr\u003e\n\n\u003cimg src=\"https://github.com/buijs-dev/klutter/blob/develop/.github/assets/metadata/icon/klutter_logo.png?raw=true\" alt=\"buijs software logo\" /\u003e\n\nThe Klutter Framework makes it possible to write a Flutter plugin for both Android\nand iOS using [Kotlin Multiplatform](https://kotlinlang.org/docs/multiplatform.html).\nInstead of writing platform specific code twice in 2 languages (Swift + Kotlin),\nit can be written once in Kotlin and used as a Flutter plugin.\n\n# Features\n\nUse this plugin if you want to:\n\n* Write platform-specific code only once for both Android and IOS in Kotlin.\n* Use Kotlin Multiplatform libraries in your Flutter app.\n* Depend on other plugins made with Klutter.\n* Auto-generate Dart code for your (native) Platform library.\n\n# Getting started\n1. [Installation](#Installation)\n2. [Using plugins](#Usage)\n3. [Creating plugins](#Creation)\n4. [FAQ](#Faq)\n\n- Start a new project with the\n  - [Intellij](https://buijs.dev/klutter-3/) plugin\n  - [Android Studio](https://buijs.dev/klutter-4/) plugin\n  - [Kradle](https://buijs.dev/kradle-1/) cli tool\n- For a step-by-step guide (doing everything manually), see the battery app with Klutter [tutorial](https://buijs.dev/klutter-2/).\n\nUsing the IDE plugins or interactive kradle tool are the \npreferred options to create projects, as opposed\nto doing everything manually. You can install\nthe kradle tool from git or pub:\n\n```shell\n## Get from pub \ndart pub global activate klutter\n\n## Get from git\ndart pub global activate --source git https://github.com/buijs-dev/klutter-dart.git\n\n## Use it globally\ndart pub global run klutter:kradle\n```\n\nA native kradle executable is added to the project workspace, \nwhen creating a new project using an IDE plugin.\n\nSee the kradle [tutorial](https://buijs.dev/kradle-1/) for usage instructions.\n\n# Installation\n\u003cb\u003eWhat's the point?\u003c/b\u003e\u003c/br\u003e\nPlugins build with the Klutter Framework work slightly different from regular plugins. \nThe Klutter dependency is a requirement for both using and creating plugins with Klutter.\n\n\u003cb\u003eSteps:\u003c/b\u003e\u003c/br\u003e\nAdd the Klutter library to dependencies in the pubspec.yaml:\n\n```yaml  \ndev_dependencies:  \n klutter: ^3.0.1\n```\n\nThen run:  \n  \n```shell  \nflutter pub get\n```\n\n# Usage\n\u003cb\u003eWhat's the point?\u003c/b\u003e\u003c/br\u003e\nPlugins build with the Klutter Framework work slightly different from regular plugins. \nThe following tasks help Flutter to locate Klutter plugins \nand ensure compatibility between Flutter Android/IOS configuration and Klutter plugin Android/IOS configuration.\n\n\u003cb\u003eSteps:\u003c/b\u003e\u003c/br\u003e\n1. Installation.\n2. Initialization.\n3. Add dependencies.\n\nInstall Klutter as dependency as described [here](#Installation).\n\nInitialize Klutter in your project by running:\n\n```shell  \ndart run klutter:kradle init\n```  \n\nThe init task will set up Klutter for both Android and iOS.\nKlutter plugins can be added by running the add command.\n\n\u003cB\u003eExample\u003c/B\u003e:\u003c/br\u003e Add the library 'awesome_plugin' to your project:\n\n```shell  \ndart run klutter:kradle add lib=awesome_plugin \n```  \n\n\u003cb\u003eBackground\u003c/b\u003e\u003c/br\u003e\nThe consumer init task will configure your Flutter project in:\n1. [IOS](#ios)\n2. [Android](#android)\n\n\u003cb\u003eIOS\u003c/b\u003e\u003c/br\u003e\nThe Podfile has to be editted to be able to run the app on an iPhone simulator.\nKlutter will look for the following code block in the Podfile:\n\n```\n post_install do |installer|\n   installer.pods_project.targets.each do |target|\n     flutter_additional_ios_build_settings(target)\n   end\n end\n```\n\nThen it will be updated to the following code:\n\n```\npost_install do |installer|\n  installer.pods_project.targets.each do |target|\n    flutter_additional_ios_build_settings(target)\n    target.build_configurations.each do |bc|\n        bc.build_settings['ARCHS[sdk=iphonesimulator*]'] =  `uname -m`\n     end\n  end\nend\n```\n\n\n\u003cb\u003eAndroid\u003c/b\u003e\u003c/br\u003e\nThe consumer init task will do the following for Android in your Flutter project:  \n 1. Create a .klutter-plugins file in the root folder.  \n 2. Create a new Gradle file in the flutter/packages/flutter_tools/gradle.  \n 3. Update the android/settings.gradle file to apply the newly generated Gradle file.  \n 4. Update the min/target SDK versions to 24/33 in the android/app/build.gradle file.\n 5. Update the Android Gradle Plugin to 8.0.2 and gradle-wrapper to Gradle 8+.\n\nThe .klutter-plugins file will register all Klutter made plugins used in your project. \nThe created Gradle file in the flutter_tools manages the plugins \nand enables them to be found by the Flutter project.  \n\nThe task klutter:add registers a Klutter plugin in the .klutter-plugins file. \nThis is then used by the Android Gradle file to find the plugin location \nand add the generated artifacts to your build.\n\n# Creation\n\u003cb\u003eWhat's the point?\u003c/b\u003e\u003c/br\u003e\nThe starting point of a Klutter plugins is a regular Flutter plugin project. \nThe following steps describe how to create a Flutter plugin project and initialize Klutter in it.\n\n\u003cb\u003eSteps:\u003c/b\u003e\u003c/br\u003e\n1. Create Flutter plugin project.\n2. [Installation](#Installation).\n3. Initialization.\n4. Build Platform module and generate Dart code.\n5. Verify your plugin.\n\nRun the following to create a new Flutter plugin, \nsubstituting 'org.example' with your organisation name \nand 'plugin_name' with your plugin name:\n\n```shell  \nflutter create --org com.example --template=plugin --platforms=android,ios -a kotlin -i swift plugin_name\n```  \n\nInstall the Klutter Framework as dependency and then run:\n\n```shell  \ndart run kradle:init  \n```  \n\nBuild the platform module by running the following in the root folder (takes a few minutes):\n\n```shell\ndart run klutter:kradle build\n```\n\nAlternatively use gradle directly with the following command:\n\n```shell\n./gradlew clean build -p \"platform\"\n```\n\nNow test the plugin by following the steps outlined [here](#Usage) in the root/example project. \nWhen done you can run the example project from the root/example/lib folder and see your first plugin in action!\n\n# Faq\n1. [App won't start on...](#App%20won't%20start)\n2. [Build fails](#build-fails)\n\n## App won't start\nMake sure you have followed all the following steps:\n- flutter create \u003cyour_plugin_name\u003e --org \u003cyour_organisation\u003e --template=plugin --platforms=android,ios -a kotlin -i swift.\n- [klutter](https://pub.dev/packages/klutter) is added to the dependencies in your pubspec.yaml \n(both the plugin and plugin/example for testing).\n- do flutter pub get in both root and root/example folder.\n- do flutter pub run klutter:kradle init in the root folder.\n- do ./gradlew clean build -p \"platform\" in the root folder.\n- do flutter pub run klutter:kradle init in the root/example folder.\n- do flutter pub run klutter:kradle add lib=\u003cyour_plugin_name\u003e in the root/example folder.\n\n### For Android emulator:\nThere should be a .klutter-plugins file in the root/example folder containing an entry for your plugin.\nIf not then do flutter pub run klutter:consumer add=\u003cyour_plugin_name\u003e in the root/example folder again.\n\nThere should be a platform.aar file in the root/android/klutter folder. \nIf not then do ./gradlew clean build -p \"platform\" from the root folder.\n\n### For iOS simulator:\nThere should be a Platform.xcframework folder in root/ios/Klutter.\nIf not then do ./gradlew clean build -p \"platform\" from the root folder.\n\nIf there's an error message saying unable to find plugin or similar then run pod update\n(or for Mac M1 users you might have to do: arch -x86_64 pod install) in the root/example/ios\nfolder.\n\nIf there's an error message saying something similiar to '...example/ios/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh: Permission denied' \nthen try one of:\n- delete the Podfile.lock and run pod install in root/example/ios folder.\n- run pod deintegrate and then pod install in root/example/ios folder.\n\n## Build fails\n1. [Java toolchain error](#java-toolchain-error)\n\n### Java toolchain error\nWhen you get an error like below, indicating no compatible Java version is detected, make sure you \nhave the same Java version installed as required by the klutter project. \n\n```shell\n* What went wrong:\n  Could not determine the dependencies of task ':klutter:hello_world:compileDebugKotlinAndroid'.\n\u003e No matching toolchains found for requested specification: {languageVersion=17, vendor=any, implementation=vendor-specific}.\n\u003e No locally installed toolchains match ...\n```\n\nYou might also have to add the following plugin to the settings.gradle(.kts) files:\n\n```kotlin\nplugins {\n    id(\"org.gradle.toolchains.foojay-resolver-convention\") version \"0.4.0\"\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbuijs-dev%2Fklutter-dart","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbuijs-dev%2Fklutter-dart","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbuijs-dev%2Fklutter-dart/lists"}