buildPopover method
Implementation
Widget buildPopover(BuildContext context) {
final theme = Theme.of(context);
final surfaceOpacity = widget.surfaceOpacity ?? theme.surfaceOpacity;
final surfaceBlur = widget.surfaceBlur ?? theme.surfaceBlur;
return MouseRegion(
hitTestBehavior: HitTestBehavior.translucent,
onEnter: (_) {
_hoverCount++;
},
onExit: (event) {
int currentHoverCount = ++_hoverCount;
Future.delayed(kDebounceDuration, () {
if (currentHoverCount == _hoverCount && mounted) {
close();
}
});
},
child: AnimatedBuilder(
animation: _activeIndex,
builder: (context, child) {
return AnimatedValueBuilder<double>(
value: _activeIndex.value.toDouble(),
duration: const Duration(milliseconds: 300),
curve: Curves.easeOutCubic,
builder: (context, value, child) {
int currentIndex = _activeIndex.value;
List<Widget> children = [];
if (currentIndex - 1 >= 0) {
children.add(
Positioned(
top: 0,
left: 0,
child: Opacity(
opacity: (1 + value - currentIndex).clamp(0.0, 1.0),
child: FractionalTranslation(
translation: Offset(-value + currentIndex - 1, 0),
child: buildContent(currentIndex - 1),
),
),
),
);
}
if (currentIndex + 1 < widget.children.length) {
children.add(
Positioned(
top: 0,
right: 0,
child: Opacity(
opacity: (1 - value + currentIndex).clamp(0.0, 1.0),
child: FractionalTranslation(
translation: Offset(-value + currentIndex + 1, 0),
child: buildContent(currentIndex + 1),
),
),
),
);
}
return OutlinedContainer(
clipBehavior: Clip.antiAlias,
borderRadius: theme.borderRadiusMd,
surfaceOpacity: surfaceOpacity,
surfaceBlur: surfaceBlur,
child: Stack(
children: [
...children,
FractionalTranslation(
translation: Offset(-value + currentIndex, 0),
child: buildContent(currentIndex),
),
],
),
);
},
);
}),
);
}