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 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.
- VerifiedFlutterVersion
- Wrapper for VersionVerifier.verifyFlutterVersion result.
Enums
- ScriptName consumer producer
- List of available scripts.
- ScriptOption consumer producer
- List of available scripts options.
- 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.
- VersionVerifier on String
- Verify if version input is valid.
Constants
- androidCompileSdk → const int
- The compile SDK version for Android.
- androidMinSdk → const int
- The minimum SDK version for Android.
- klutterFlutterVersion → const String
- The default Flutter version to be used in the Klutter project.
- 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.
-
supportedFlutterVersions
→ const Set<
String> - Flutter SDK versions which can be used for a Producer project.
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< consumer producerTask> ? tasks]) → Set<Task> - 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.
-
deleteRootAndroidManifestFile(
{required String pathToAndroid}) → void producer - Delete the root/android/src/main/AndroidManifest.xml File because it is only used to set the package name, which is not supported from AGP 8.0+.
-
download(
String endpoint, File target) → Future< void> - Download a File.
-
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/kradle.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.
-
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.
-
setGradleWrapperVersion(
{required String pathToAndroid}) → void - Set the version in the gradle-wrapper.properties.
-
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. -
unzip(
File zip, Directory target) → Future< void> - Unzip a File.
-
writeAndroidAppBuildGradleFile(
{required String pathToAndroid, required String packageName, required String pluginName}) → void consumer - Overwrite the build.gradle File in android/app.
-
writeAndroidBuildGradleFile(
{required String pathToAndroid, required String packageName, required String pluginName}) → void consumer - Overwrite the build.gradle File in android.
-
writeAndroidPlugin(
{required String pathToAndroid, required String packageName, required String pluginName}) → void producer - Overwrite the method channel Kotlin Class in src/main/kotlin.
-
writeBuildGradleFile(
{required String pathToAndroid, required String packageName, required String pluginName, 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.