hue_rotation 3.0.0
hue_rotation: ^3.0.0 copied to clipboard
Change the color of any widget that has a color. Like SwiftUI's Hue Rotation.
hue_rotation #
Apply a hue rotation to any Flutter widget subtree using a color matrix.
Installation #
Flutter 3.47+
dependencies:
hue_rotation: ^3.0.0
Flutter 3.10–<3.47
dependencies:
hue_rotation: ^2.0.2
Usage #
import 'package:flutter/widgets.dart';
import 'package:hue_rotation/hue_rotation.dart';
const HueRotation(
degrees: 90,
child: SizedBox(
width: 64,
height: 64,
child: ColoredBox(color: Color(0xff2196f3)),
),
)
degrees accepts positive, negative, and fractional angles. Zero and full turns leave colors unchanged. Alpha is preserved. A half-turn (180) uses the hue rotation matrix; it is not RGB inversion or an HSV hue adjustment. Output channels outside the display gamut are clamped, so brightness and saturation can appear different.
Update degrees from an animation to animate the filter. See the example for static and animated rotations of Colors.blue.
Upgrading to 3.0.0 #
The widget API is unchanged. Mobile host apps follow Flutter’s minimums (iOS 15 and Android API 24 on Flutter 3.47), or any higher minimum required by the app.
HueRotation in action #
