Skip to content

Instantly share code, notes, and snippets.

@loic-sharma
Last active February 5, 2026 19:55
Show Gist options
  • Select an option

  • Save loic-sharma/56a218031b9e5d757654abd5d09d6462 to your computer and use it in GitHub Desktop.

Select an option

Save loic-sharma/56a218031b9e5d757654abd5d09d6462 to your computer and use it in GitHub Desktop.
class _MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(
children: [
ExpensiveWidget(focusNode: _node),
StateBuilder<double>(
create: (BuildContext context) => 1.0,
builder: (BuildContext context, double opacity, SetStateCallback<double> setOpacity) {
return GestureDetector(
onTap: () => setOpacity(opacity == 1.0 ? 0.5 : 1.0),
child: Opacity(opacity: opacity, child: widget.child),
);
},
),
],
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment