Home > Mobile >  How to change widget brightness in Flutter?
How to change widget brightness in Flutter?

Time:07-01

In CSS I can use filter to change brightness. It's easy to make button hover effect.

filter: brightness(1.1);

filter: brightness(0.9);

Is there any way to change widget brightness in Flutter?

CodePudding user response:

If your main goal is giving a hover effect on a button, you can use the combination of animated container(for the effect) and inkwell(onHover method to notify when hovering happens)

AnimatedContainer(
      height: 70,
      duration: Duration(milliseconds: 200),
      padding: EdgeInsets.only(
          top: (isHover) ? 25 : 30.0, bottom: !(isHover) ? 25 : 30),
      child: Container(
        height: 30,
        color: Colors.blue,
        child: InkWell(
          onTap: () {},
          child: Text("Hover Button"),
          onHover: (val) {
            print("Val--->{}$val");
            setState(() {
              isHover = val;
            });
          },
        ),

CodePudding user response:

We do this in flutter

Colors.red.withOpacity(1.1);
  • Related