Skip to content

Instantly share code, notes, and snippets.

@JulianBissekkou
Created February 17, 2019 19:07
Show Gist options
  • Save JulianBissekkou/b9aeb684416ae7aecb20f82fe0eccdd7 to your computer and use it in GitHub Desktop.
Save JulianBissekkou/b9aeb684416ae7aecb20f82fe0eccdd7 to your computer and use it in GitHub Desktop.
class ReachableIcon extends StatefulWidget {
final Widget child;
final int index;
final VoidCallback onSelect;
ReachableIcon({
@required this.child,
@required this.index,
@required this.onSelect,
});
@override
_ReachableIconState createState() => _ReachableIconState();
}
class _ReachableIconState extends State<ReachableIcon> {
bool _isFocused = false;
@override
Widget build(BuildContext context) {
return Reachable(
index: widget.index,
onSelect: widget.onSelect,
onFocusChanged: (isFocused) {
setState(() => _isFocused = isFocused);
},
child: AnimatedContainer(
duration: Duration(milliseconds: 200),
decoration: BoxDecoration(
color: _isFocused ? Colors.black45 : Colors.transparent,
shape: BoxShape.circle,
),
padding: EdgeInsets.all(16),
alignment: Alignment.center,
child: widget.child,
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment