kOpenBorderRadius constant
Exposes the default border radius for matching iOS 16.0 behavior. This value was eyeballed from the iOS simulator running iOS 16.0.
Below is example code in order to match the default border radius for an
iOS 16.0 open preview.
link
CupertinoContextMenu.builder(
actions: <Widget>[
CupertinoContextMenuAction(
child: const Text('Action one'),
onPressed: () {},
),
],
builder:(BuildContext context, Animation<double> animation) {
final Animation<BorderRadius?> borderRadiusAnimation = BorderRadiusTween(
begin: BorderRadius.circular(0.0),
end: BorderRadius.circular(CupertinoContextMenu.kOpenBorderRadius),
).animate(
CurvedAnimation(
parent: animation,
curve: Interval(
CupertinoContextMenu.animationOpensAt,
1.0,
),
),
);
final Animation<Decoration> boxDecorationAnimation = DecorationTween(
begin: const BoxDecoration(
boxShadow: <BoxShadow>[],
),
end: const BoxDecoration(
boxShadow: CupertinoContextMenu.kEndBoxShadow,
),
).animate(
CurvedAnimation(
parent: animation,
curve: Interval(
0.0,
CupertinoContextMenu.animationOpensAt,
),
)
);
return Container(
decoration:
animation.value < CupertinoContextMenu.animationOpensAt ? boxDecorationAnimation.value : null,
child: FittedBox(
fit: BoxFit.cover,
child: ClipRRect(
borderRadius: borderRadiusAnimation.value ?? BorderRadius.circular(0.0),
child: SizedBox(
height: 150,
width: 150,
child: Image.network('https://flutter.github.io/assets-for-api-docs/assets/widgets/owl-2.jpg'),
),
),
)
);
},
)
Implementation
static const double kOpenBorderRadius = _previewBorderRadiusRatio;