klutter library

The Klutter Framework makes it possible to write a Flutter plugin for both Android and iOS using Kotlin Multiplatform.

Instead of writing platform specific code twice in 2 languages (Swift + Kotlin), it can be written once in Kotlin and used as a Flutter plugin.

Classes

Command
Object to store parsed user input.
ConsumerAdd consumer
Task to add a Klutter-made Flutter plugin to a Flutter project.
ConsumerInit consumer
Task to prepare a Flutter project for using Klutter-made plugins.
Gradle producer gradle
Copy Gradle files to root and root/android folders to enable the usage of Gradle.
PlatformModule
The root/platform module containing the Kotlin Multiplatform sourcecode.
ProducerInit producer
Task to run project initialization (setup).
Task
Interface to encapsulate CLI task functionality.
TaskResult
Result object indicating a Task was executed successfully or not.

Enums

ScriptName consumer producer
List of available scripts.
TaskName
List of available tasks.

Extensions

ColoredMessage on String
Output log message to console.
FileUtil on FileSystemEntity
File management utilities.
StringUtil on String
Utils for easier String manipulation.
TaskNameParser on String?
Convert a String value to a TaskName.

Constants

androidCompileSdk → const int
The compile SDK version for Android.
androidMinSdk → const int
The minimum SDK version for Android.
androidTargetSdk → const int
The target SDK version for Android.
klutterGradleVersion → const String
The version of the Klutter Gradle Plugin.
klutterPubVersion → const String
The version of the Klutter Pub Plugin.
kotlinVersion → const String
The version of Kotlin to be used.

Properties

printTasksAsCommands String
Print all possible user input commands based of the available Tasks.
no setter

Functions

addFrameworkToPodspec({required String pathToIos, required String pluginName}) → void producer
Edit the root/ios/
allTasks([List<Task>? tasks]) Set<Task> consumer producer
List of all Task objects.
applyPluginLoader(String pathToAndroid) → void consumer
Add apply plugin line to android/settings.gradle file.
compareByDependsOn(Task t1, Task t2) int
Comparator function to sort Tasks based on their dependencies.
createIosKlutterFolder(String pathToIos) → void producer
Overwrite the build.gradle file in the root/android folder.
createPlatformModule({required String pathToRoot, required String pluginName, required String packageName}) → void producer
Generate the Kotlin Multiplatform module.
createRegistry(String pathToRoot) File consumer
Create registry file .klutter-plugins.
execute({required ScriptName script, required String pathToRoot, required List<String> arguments}) Future<String>
Main entrypoint for executing Klutter command line tasks.
findDependencyPath({required String pathToSDK, required String pathToRoot, required String pluginName}) String consumer producer
Get the relative path of a plugin dependency.
findFlutterSDK(String pathToAndroid) String consumer
Get the path to the local Flutter SDK installation as configured in the root-project/android/local.properties folder.
findKlutterBomVersion(String pathToRoot) String? consumer producer
Find the version of klutter bill-of-materials in root/klutter.yaml or return null.
findPackageName(String pathToRoot) String consumer producer
Find package name in root/pubspec.yaml.
findPluginName(String pathToRoot) String consumer producer
Find plugin name in root/pubspec.yaml.
findPluginVersion(String pathToRoot) String consumer producer
Find plugin name in root/pubspec.yaml.
loadResource({required Uri uri, required String filename, required String targetRelativeToRoot}) Future<_GradleResource>
Load resource files from lib/res folder.
registerPlugin({required String pathToRoot, required String pluginName, required String pluginLocation}) → void consumer
Create and/or append the .klutter-plugins file to register a Klutter plugin.
setAndroidSdkConstraints(String pathToAndroid) → void consumer
Update Android SDK version constraints in the root/android/build.gradle file.
setKotlinVersionInBuildGradle(String pathToAndroid) → void consumer
Update the kotlin_version variable in root/android/build.gradle file to kotlinVersion.
tasksOrEmptyList(Command command, [Set<Task>? tasks]) Set<Task>
Get the Task and all tasks it relies on or return empty list if command is invalid.
toPluginClassName(String pluginName, {bool postfixWithPlugin = false}) String consumer producer
The plugin ClassName which is equal to the library name converted to camelcase + 'Plugin' postfix if postfixWithPlugin is set to true.
writeAndroidPlugin({required String pathToAndroid, required String packageName}) → void producer
Overwrite the method channel Kotlin Class in src/main/kotlin.
writeBuildGradleFile({required String pathToAndroid, required String packageName, required String pluginVersion, required String klutterBomVersion}) → void producer
Overwrite the build.gradle file in the root/android folder.
writeExampleMainDartFile({required String pathToExample, required String pluginName}) → void producer
Generate the main.dart file in the root/example/lib folder.
writeGradleProperties(String pathToRoot) → void producer gradle
Generate the build.gradle.kts file in the root folder.
writeKlutterGradleFile(String pathToAndroid) → void producer
Create the android/klutter folder if it does not exist.
writePluginLoaderGradleFile(String pathToFlutterSDK) → void consumer
Generate a new gradle file in the flutter/tools/gradle folder which will apply Klutter plugins to a Flutter project.
writeRootBuildGradleFile({required String pathToRoot, required String pluginName, required String klutterBomVersion}) → void producer gradle
Generate the build.gradle.kts file in the root folder.
writeRootSettingsGradleFile({required String pathToRoot, required String pluginName}) → void producer gradle
Generate the settings.gradle.kts file in the root folder.

Exceptions / Errors

KlutterException
Exception indicating a problem with the Klutter Framework either internally or by faulty configuration.