forTypeWithVariableResolver static method
Returns a ResolvableType for the specified Type backed by a VariableResolver.
This factory method creates a ResolvableType with a specific VariableResolver for resolving type variables. This provides fine-grained control over how type variables are resolved in generic contexts.
Parameters:
type
: The Type to create a ResolvableType forvariableResolver
: Optional VariableResolver for type variable resolution
Returns:
- ResolvableType with the specified VariableResolver
Example:
// Create a custom variable resolver
class CustomVariableResolver implements VariableResolver {
@override
Object getSource() => this;
@override
ResolvableType? resolveVariable(Object variable) {
// Custom resolution logic
if (variable == someTypeVariable) {
return ResolvableType.forClass(String);
}
return null;
}
}
final customResolver = CustomVariableResolver();
final typeWithResolver = ResolvableType.forTypeWithVariableResolver(
someGenericType,
customResolver
);
// The type will use the custom resolver for type variable resolution
Implementation
static ResolvableType forTypeWithVariableResolver(Type type, VariableResolver? variableResolver) {
return forTypeWithProviderAndResolver(type, null, variableResolver);
}