1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-10 14:58:34 +00:00

Enable the context menu examples on web (#1687)

This commit is contained in:
Justin McCandless
2023-03-01 18:33:12 -08:00
committed by GitHub
parent b4c64cff9a
commit 7874e554b6
3 changed files with 21 additions and 4 deletions

View File

@@ -1,5 +1,6 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'anywhere_page.dart';
import 'cascading_menu_page.dart';
@@ -35,6 +36,24 @@ class _MyAppState extends State<MyApp> {
});
}
@override
void initState() {
super.initState();
// On web, disable the browser's context menu everywhere so that the custom
// Flutter-rendered context menu shows.
if (kIsWeb) {
BrowserContextMenu.disableContextMenu();
}
}
@override
void dispose() {
if (kIsWeb) {
BrowserContextMenu.enableContextMenu();
}
super.dispose();
}
@override
Widget build(BuildContext context) {
return MaterialApp(