D4UserBridge class abstract
Base class for user-defined bridge overrides.
Extend this class to provide custom implementations for specific bridge
members that the generator cannot handle correctly (e.g., operators,
complex generics, or classes needing nativeNames).
This is a marker class - extending it tells the generator:
- This class should be excluded from bridge generation
- Static methods matching the override naming convention should be used
Naming Convention
Create a class named {ClassName}UserBridge that extends D4UserBridge:
class MyListUserBridge extends D4UserBridge {
// Static override methods...
}
Override Methods (all must be static)
| Member Type | Static Override Method |
|---|---|
Constructor Foo() |
static overrideConstructor(...) |
Constructor Foo.named() |
static overrideConstructorNamed(...) |
Getter value |
static overrideGetterValue(...) |
Setter value= |
static overrideSetterValue(...) |
Method doWork() |
static overrideMethodDoWork(...) |
| Static getter | static overrideStaticGetterName(...) |
| Static setter | static overrideStaticSetterName(...) |
| Static method | static overrideStaticMethodName(...) |
Operator [] |
static overrideOperatorIndex(...) |
Operator []= |
static overrideOperatorIndexAssign(...) |
Operator + |
static overrideOperatorPlus(...) |
Special Properties
nativeNames: Define as a static getter to provide internal type names
Example
class MyListUserBridge extends D4UserBridge {
/// Map internal List implementations to this bridge.
static List<String> get nativeNames => ['_GrowableList', '_FixedLengthList'];
/// Override operator[] - not auto-generated.
static Object? overrideOperatorIndex(
Object? visitor,
Object? target,
List<Object?> positional,
Map<String, Object?> named,
) {
final list = D4.validateTarget<MyList>(target, 'MyList');
final index = D4.getRequiredArg<int>(positional, 0, 'index', '[]');
return list[index];
}
}
The generator will:
- Detect
MyListUserBridgeextendingD4UserBridge - Skip
MyListUserBridgefrom bridge generation - For class
MyList, check ifMyListUserBridgeexists - Use
MyListUserBridge.overrideOperatorIndexinstead of generating[] - Use
MyListUserBridge.nativeNamesin the generatedBridgedClass
Constructors
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