简易侧边菜单

logo

GitHub Pub Version GitHub repo size

Easy sidemenu 是一个易于使用的 Flutter 侧边菜单(栏),可用于应用程序中的导航。

侧边菜单通常位于页面左侧或右侧,可用于导航或其他用途。侧边菜单类似于底部导航栏,但位于屏幕侧面,通常用于较大的屏幕。

截图

展开 紧凑
Open Compact
自动
Auto

演示

您可以在此处查看 Web 演示: https://jamalianpour.github.io/easy_sidemenu

用法

1. 将依赖项添加到您的项目 pubspec.yaml 文件中

dependencies:
  easy_sidemenu: ^0.1.1+1

在您的应用程序的根目录下运行 flutter packages get

2. 导入 easy sidemenu 库

import 'package:easy_sidemenu/easy_sidemenu.dart';

现在您可以在代码中使用 SideMenu 作为小部件。

3. 使用 SideMenu

首先,您应该定义一个将显示在 SideMenu 中的项目列表

<div class="highlight highlight-source-dart position-relative" data-snippet-clipboard-copy-content="List items = [
SideMenuItem(
// 在 SideMenu 中显示的优先级,值越低显示在顶部
priority: 0,
title: ‘仪表盘’,
onTap: () => page.jumpToPage(0),
icon: Icons.home,
),
SideMenuItem(
priority: 1,
title: ‘设置’,
onTap: () => page.jumpToPage(1),
icon: Icons.settings,
),
SideMenuItem(
priority: 2,
title: ‘退出’,
onTap: () {},
icon: Icons.exit_to_app,
),
];
“>

List<SideMenuItem> items = [
  SideMenuItem(
    // Priority of item to show on SideMenu, lower value is displayed at the top
    priority: 0,
    title: 'Dashboard',
    onTap: () => page.jumpToPage(0),
    icon: Icons.home,
  ),
  SideMenuItem(
    priority: 1,
    title: 'Settings',
    onTap: () => page.jumpToPage(1),
    icon: Icons.settings,
  ),
  SideMenuItem(
    priority: 2,
    title: 'Exit',
    onTap: () {},
    icon: Icons.exit_to_app,
  ),
];