setMockDynamicColors static method
Initializes the dynamic color plugin with mock values for testing.
Implementation
@visibleForTesting
static void setMockDynamicColors({
CorePalette? corePalette,
Color? accentColor,
}) {
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(DynamicColorPlugin.channel, (
MethodCall methodCall,
) async {
if (methodCall.method == DynamicColorPlugin.methodName) {
return corePalette != null
? Int64List.fromList(corePalette.asList())
: null;
} else if (methodCall.method ==
DynamicColorPlugin.accentColorMethodName) {
return accentColor?.value;
} else {
return null;
}
});
addTearDown(() {
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(
DynamicColorPlugin.channel,
(MethodCall methodCall) => null,
);
});
}