flutter context menu code example
Example: cupertino context menu example
import 'package:flutter/cupertino.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return CupertinoApp(
debugShowCheckedModeBanner: false,
title: 'Kindacode.com',
home: MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return SafeArea(
child: CupertinoPageScaffold(
child: CupertinoContextMenu(
actions: [
CupertinoContextMenuAction(
child: Text('Add to Favorites'),
onPressed: () {
Navigator.of(context).pop();
},
),
CupertinoContextMenuAction(
child: Text('Download'),
onPressed: () {
Navigator.of(context).pop();
},
),
CupertinoContextMenuAction(
child: Text('Report this image'),
onPressed: () {
Navigator.of(context).pop();
},
)
],
child: Image.network(
'https://www.kindacode.com/wp-content/uploads/2020/10/dog_sample.jpg'))
),
);
}
}