cv_side_menu 0.0.1+1 copy "cv_side_menu: ^0.0.1+1" to clipboard
cv_side_menu: ^0.0.1+1 copied to clipboard

an easy side menu

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:cv_side_menu/cv_side_menu.dart';

import 'cv_home_page.dart';
import 'some_page_has_menu.dart';

void main() {
  runApp(const MyApp());
}

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        // This is the theme of your application.
        //
        // TRY THIS: Try running your application with "flutter run". You'll see
        // the application has a purple toolbar. Then, without quitting the app,
        // try changing the seedColor in the colorScheme below to Colors.green
        // and then invoke "hot reload" (save your changes or press the "hot
        // reload" button in a Flutter-supported IDE, or press "r" if you used
        // the command line to start the app).
        //
        // Notice that the counter didn't reset back to zero; the application
        // state is not lost during the reload. To reset the state, use hot
        // restart instead.
        //
        // This works for code too, not just values: Most code changes can be
        // tested with just a hot reload.
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const SideMenuPage(title: 'Flutter Demo Home Page'),
    );
  }
}

class SideMenuPage extends StatefulWidget {
  const SideMenuPage({super.key, required this.title});

  final String title;

  @override
  State<SideMenuPage> createState() => _SideMenuPageState();
}

class _SideMenuPageState extends State<SideMenuPage> {
  List<SideMenuItem> items = const [
    SideMenuItem(
      page: SomePageHasMenu(),
      routePath: "/somePageHasMenu",
      id: 99,
      title: "SomePageHasMenu",
      leadingIconData: Icons.ac_unit,
    ),
    SideMenuItem(
      page: PageA(),
      routePath: "/pageA",
      id: 1,
      title: "page a",
      leadingIconData: Icons.ac_unit,
    ),
    SideMenuItem(
        id: 3,
        title: "page c",
        routePath: "exp/page",
        leadingIconData: Icons.baby_changing_station,
        trailingIconData: Icons.arrow_drop_down_outlined,
        expItem: [
          SideMenuItem(
            page: PageX(),
            routePath: "/pageX",
            id: 10,
            title: "page X",
            leadingIconData: Icons.ac_unit,
          ),
          SideMenuItem(
            page: PageQ(),
            routePath: "/pageQ",
            id: 11,
            title: "page Q",
            leadingIconData: Icons.ac_unit,
          ),
        ]
    ),
  ];

  final SideMenuStyle menuStyle = SideMenuStyle(
    itemSelectBGColor: Colors.blue,
    itemHeight: 35,
    // itemUnselectColor: Colors.grey,
    menuWidth: 200,
    // titleStyle: TextStyle(fontSize: 50)
  );

  // final SideMenuStyle expStyle = SideMenuStyle(
  //     itemSelectBGColor: Colors.white,
  //     itemUnselectBGColor: Colors.white,
  //     itemSelectColor: Colors.blue,
  //     itemHeight: 35,
  //     itemUnselectColor: Colors.grey);


  Widget _leading (){
    return const Row(
      children: [
        Icon(Icons.access_alarms_outlined,size: 51,),
        Text("some slogan"),
      ],
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title:ConstrainedBox(
          constraints: const BoxConstraints(maxWidth: 400,maxHeight: 35),
          child: const TextField(
            textAlign: TextAlign.center,
            decoration: InputDecoration(
              hintText: '搜索',
              border: OutlineInputBorder(),
              contentPadding: EdgeInsets.symmetric(horizontal: 10),
            ),
          ),
        ),
        leading: _leading(),
        actions: [
          ElevatedButton(onPressed: (){}, child: const Text("退出"))
        ],
        leadingWidth: 250,
      ),
      body: Row(
        mainAxisAlignment: MainAxisAlignment.start,
        children: [
          CVSideMenu(
            menuItems: items,
            style: menuStyle,
            // expStyle: expStyle,
          ),
          CVSideMenuContent(items: items,defaultPage:const Page404(),)
        ],
      ),
    );
  }
}
1
likes
70
points
10
downloads

Publisher

unverified uploader

Weekly Downloads

an easy side menu

Homepage

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter

More

Packages that depend on cv_side_menu