createOverLay method
void
createOverLay()
Implementation
void createOverLay() {
Color color =
widget.color == null ? Color.fromRGBO(28, 39, 82, 0.95) : widget.color!;
Color txtColor = widget.txtColor == null
? Color.fromRGBO(171, 189, 255, 1)
: widget.txtColor!;
RenderBox? renderBox = context.findRenderObject() as RenderBox?;
var screenSize = renderBox!.size;
print("screenSize:" + screenSize.toString());
renderBox = _tapWidget.currentContext!.findRenderObject() as RenderBox?;
var parentSize = renderBox!.size;
var parentPosition = renderBox.localToGlobal(Offset.zero);
var appbarBottomHeight = 0.0;
RenderBox? appbarBottomRenderBox = _appbottomWidget.currentContext == null
? null
: _appbottomWidget.currentContext!.findRenderObject() as RenderBox;
if (appbarBottomRenderBox != null) {
appbarBottomHeight = appbarBottomRenderBox.size.height;
}
overlayEntry = new OverlayEntry(builder: (context) {
return new Positioned(
top: parentPosition.dy + parentSize.height - appbarBottomHeight,
child: Material(
child: Container(
color: color,
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height -
(parentPosition.dy +
parentSize.height -
appbarBottomHeight),
child: ListTreeView(
shrinkWrap: false,
padding: EdgeInsets.all(0),
itemBuilder: (BuildContext context, NodeData data) {
MenuItem item = data as MenuItem;
double offsetX = item.level * 16.0;
return Container(
height: 54,
padding: EdgeInsets.symmetric(horizontal: 16),
decoration: BoxDecoration(
color: color,
border: Border(
bottom:
BorderSide(width: 1, color: Colors.grey))),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Expanded(
child: Padding(
padding: EdgeInsets.only(left: offsetX),
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text(
'${item.name}',
style: TextStyle(
fontSize: 15, color: txtColor),
),
SizedBox(
width: 10,
),
],
),
),
),
Visibility(
visible:
item.children.length > 0,
child: Container(
child: InkWell(
onTap: () {
_controller.expandOrCollapse(item.index);
},
child: Icon(
Icons.arrow_drop_down,
color: txtColor,
size: 30,
),
),
))
],
),
);
},
onTap: (NodeData data) {
MenuItem item = data as MenuItem;
print('name = ${item.name}');
print('index = ${item.index}');
if (widget.menuItemClick != null) {
widget.menuItemClick!(item);
}
},
onLongPress: (data) {},
controller: _controller,
toggleNodeOnTap: true,
)),
));
});
}