ipados_menu_bar 0.0.3 copy "ipados_menu_bar: ^0.0.3" to clipboard
ipados_menu_bar: ^0.0.3 copied to clipboard

A Flutter package that brings the iPadOS menubar to your apps, offering a native-like, customizable menu experience for iPad.

example/lib/main.dart

import 'package:flutter/cupertino.dart';
import 'dart:async';
import 'package:ipados_menu_bar/ipados_menu_bar.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  WidgetsBinding.instance.platformMenuDelegate = IpadOSPlatformMenuDelegate();
  debugPrint(
    "Platform menu delegate set: ${WidgetsBinding.instance.platformMenuDelegate}",
  );

  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  late IpadOSPlatformMenuDelegate _menuDelegate;
  bool toggledOption = false;

  @override
  void initState() {
    super.initState();
    _menuDelegate =
        WidgetsBinding.instance.platformMenuDelegate
            as IpadOSPlatformMenuDelegate;
    _configureDefaultMenus();
  }

  Future<void> _configureDefaultMenus() async {
    await _menuDelegate.configureDefaultMenus({
      'file': {
        'additionalItems': [
          {'id': 100, 'label': 'Mi Nuevo Archivo', 'enabled': true},
          {'id': 101, 'label': 'Mi Abrir Especial', 'enabled': true},
        ],
      },
      'edit': {
        'additionalItems': [
          {'id': 102, 'label': 'Mi Función Personalizada', 'enabled': true},
        ],
      },
      'hidden': ['format', 'file', 'edit'],
    });
  }

  @override
  Widget build(BuildContext context) {
    return CupertinoApp(
      home: CupertinoPageScaffold(
        navigationBar: CupertinoNavigationBar(
          middle: const Text('iPadOS 26+ menu bar plugin example app'),
        ),
        child: PlatformMenuBar(
          menus: [
            PlatformMenu(
              label: 'Test Menu',
              menus: [
                PlatformMenuItem(
                  label: 'Item 0 (Enabled: $toggledOption)',
                  onSelected: toggledOption
                      ? () => debugPrint("Item 0 selected")
                      : null,
                ),
                PlatformMenuItemGroup(
                  members: [
                    PlatformMenuItem(
                      label: 'Item 1',
                      onSelected: () => debugPrint("Item 1 selected"),
                    ),
                    PlatformMenuItem(
                      label: 'Item 2',
                      onSelected: () => debugPrint("Item 2 selected"),
                    ),
                  ],
                ),
                PlatformMenuItem(
                  label: 'Item 3',
                  onSelected: () => debugPrint("Item 3 selected"),
                ),
              ],
            ),
            PlatformMenu(
              label: 'Another Test Menu',
              menus: [
                PlatformMenuItem(
                  label: 'Toggled: $toggledOption',
                  onSelected: () => setState(() {
                    toggledOption = !toggledOption;
                  }),
                ),
                if (toggledOption)
                  PlatformMenu(
                    label: "Unlocked Secrets",
                    menus: [
                      PlatformMenuItem(
                        label: 'Secret item',
                        onSelected: () => debugPrint("Secret selected"),
                      ),
                      PlatformMenuItem(
                        label: 'Button that gives you 1M dollars',
                      ),
                    ],
                  ),
              ],
            ),
          ],
          child: Center(
            child: Text(
              "Swipe down from the top of the screen to see the magic happen",
            ),
          ),
        ),
      ),
    );
  }
}
7
likes
0
points
19
downloads

Publisher

verified publishersorolla.studio

Weekly Downloads

A Flutter package that brings the iPadOS menubar to your apps, offering a native-like, customizable menu experience for iPad.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on ipados_menu_bar

Packages that implement ipados_menu_bar