How to add tap or longpress (any gestureDector event) on longpressed DialogBox
clicking on icons on popop after showing that, can we swipe on icons and getting action like with click?
hear i'am, using "OverlyEntery" to show dialog, iam using overlyEntry because it will keep the gesture longpress event, it's work fine when longpress show the Dialog and disappear when longpressEnd event occurred, but the problem is after open a dialog Box, in Dialog box i was not able to add any event, hear i want like instagram image preview.
Thank you.
import 'package:flutter/material.dart';
class Explore extends StatelessWidget {
Explore({Key? key}) : super(key: key);
OverlayEntry _popUp({required String url}) {
return OverlayEntry(
builder: (context) => Dialog(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
width: double.infinity,
padding: EdgeInsets.all(10.0),
color: Colors.black,
child: Center(
child: Text(
"Trip Body name",
style: TextStyle(color: Colors.white),
)),
),
Image.asset(url),
Container(
color: Colors.black,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
GestureDetector(
onLongPress: () {
print("press1");
},
onLongPressCancel: () {
print("press2");
},
onLongPressDown: (e) {
print("press3");
},
onLongPressMoveUpdate: (d) {
print("press4");
},
child: Container(
child: const Icon(
Icons.favorite,
color: Colors.white,
)),
),
Icon(Icons.save)
],
),
)
],
)));
}
OverlayEntry? _popUpDialog;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: StaggeredGridView.countBuilder(
// controller: _scrollController,
crossAxisCount: 2,
itemCount: 50,
itemBuilder: (BuildContext context, int index) => InkWell(
onTap: () {
},
child: GestureDetector(
// behavior: HitTestBehavior.deferToChild,
onLongPress: () {
_popUpDialog = _popUp(
url: 'assets/images/a' +
((index < 15)
? index.toString()
: index > 20
? '3'
: (index - 10).toString()) +
'.jpeg');
Overlay.of(context)!.insert(_popUpDialog!);
},
onLongPressEnd: (d) {
_popUpDialog!.remove();
},
child: Image.asset((
'assets/images/a' +
((index < 15)
? index.toString()
: index > 20
? '3'
: (index - 10).toString()) +
'.jpeg'
)),
),
staggeredTileBuilder: (int index) => StaggeredTile.count(
1, isForReel(index: index) ? 1.5 : 1), // 2,11,23,30,44
mainAxisSpacing: 4.0,
crossAxisSpacing: 4.0,
),
),
)
]
)
);
}
}