We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
extension TextColor on Color { static Color Function(Color) luminanceDyer({ Color light = Colors.white, Color dark = Colors.black, }) => (color) => color.computeLuminance() > 0.5 ? dark : light; Color dye(Color Function(Color) dyer) => dyer(this); Color luminance({ Color light = Colors.white, Color dark = Colors.black, }) => TextColor.luminanceDyer(light: light, dark: dark).call(this); } void main() { final dyer = TextColor.luminanceDyer( light: Colors.white, dark: Colors.black, ); Colors.white.dye(dyer); // Colors.black Colors.black.dye(dyer); // Colors.white Colors.greenAccent.dye(dyer); // Colors.black Colors.green.dye(dyer); // Colors.white } class ExampleWidget extends StatelessWidget { final Color? color; const ExampleWidget({ Key? key, this.color, }) : super(key: key); @override Widget build(BuildContext context) { return Container( color: color?.luminance( light: Colors.white, dark: Colors.black87, ), ); } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The text was updated successfully, but these errors were encountered: