showMyDialog method
Method to calculate alert.
Implementation
Future<void> showMyDialog(
BuildContext context,
Offset dataPosition, {
String? dialogText,
}) async {
RenderBox box = globalKey?.currentContext?.findRenderObject() as RenderBox;
double dx = dataPosition.dx;
Offset offset = box.localToGlobal(Offset.zero);
return showDialog<void>(
barrierColor: Colors.transparent,
context: context,
barrierDismissible: true, // user must tap button!
builder: (BuildContext context) {
return MultipleInfoDialog(
/// Make the background transparent.
elevation: 0,
/// The orientation determines the dialog coordinates.
rect: RadData.horizontal == radData
? Rect.fromLTWH(
offset.dx,
offset.dy - (boxSize ?? 0),
box.size.width,
(contextSize?.width ?? 0) / 3,
)
: Rect.fromLTWH(
offset.dx,
offset.dy.ceilToDouble() -
((navigationHeight ?? 0) + dx.floorToDouble()),
(contextSize?.width ?? 0) / 3,
(contextSize?.width ?? 0) / 3,
),
content: SingleChildScrollView(
child: Column(
children: [
const Padding(padding: EdgeInsets.only(top: 8)),
/// Characters to be changed
Text(
dialogText == "" ? dx.toStringAsFixed(1) : dialogText ?? "",
),
const Padding(padding: EdgeInsets.only(bottom: 16)),
OutlinedButton(
onPressed: () {
Navigator.of(context).pop();
},
child: const Text('OK', style: TextStyle(fontSize: 10)),
),
],
),
),
);
},
);
}