GradleEditor class
Inserts a flavorDimensions + productFlavors block into a Flutter-
generated Android app gradle file. Handles both the Kotlin DSL
(build.gradle.kts) and the legacy Groovy DSL (build.gradle).
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
apply(
ProjectConfig config) → void -
Edits
android/app/build.gradle{.kts}inconfig's project to add the product flavors. No-op (with a warning) when there are no flavors, no gradle file (e.g.flutter createwas skipped), or the block already exists. Throws StateError if the file exists but has noandroid { }block to edit. -
applyManifest(
ProjectConfig config) → void -
Rewrites
android/app/src/main/AndroidManifest.xmlso the app label reads from the per-flavorapp_namestring resource (defined viaresValuein apply) instead of a hard-coded value. Without this, theresValueentries are inert and every flavor shows the same name. -
injectProductFlavors(
String content, {required bool isKts, required List< FlavorGradle> flavors}) → String -
Pure transform: returns
contentwith the flavors block inserted just before the closing brace of theandroid { }block. Exposed for testing. -
setAppLabelToResource(
String manifest) → String -
Pure transform: replaces the
android:label="..."attribute value with@string/app_name. Exposed for testing. Throws StateError when the attribute is absent. Idempotent — re-running on an already-wired manifest returns it unchanged.