gzx_dropdown_menu 1.0.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 89

gzx_dropdown_menu #

自定义功能强大的下拉筛选菜单flutter package

  • Custom dropdown header
  • Custom dropdown header item
  • Custom dropdown menu
  • Custom dropdown menu show animation time
  • Control dropdown menu show or hide

开源不易,麻烦给个Star吧!我会根据大家的关注度和个人时间持续更新代码! #

相关Repository #

Flutter 淘宝App

相关文章 #

掘金

导航 #

Gif效果图 #

分别是仿美团和淘宝的效果图
美团的代码就在这个仓库的example目录下
淘宝的代码在Flutter 淘宝,点我打开

如何使用 #

目前已发布到Pub,你可以在Pub官网查看最新的版本和更新说明!点我去Pub官网查看

1、添加gzx_dropdown_menu package #

打开pubspec.yaml文件 如我想使用1.0.1版本,则添加如下代码

  gzx_dropdown_menu : ^1.0.1

添加后打开Terminal,执行flutter packages get

2、使用 #

打开本仓库example项目下的gzx_dropdown_menu_test_page.dart文件自己看。

没空编辑文字了,而且说这么多还不如你直接运行下看下效果,然后看下代码,就知道如何使用了。

~~算了~~🤪🤪🤪🙄还是简单说下吧!!!
你只需要将GZXDropDownHeader和GZXDropDownMenu嵌套到你的代码中即可

GZXDropDownHeader #

这里要注意了,这些参数不是必须要要写的,我写出来只是让你知道强大的自定义功能,实际上就前面三个参数是必填的

  // 下拉菜单头部
  GZXDropDownHeader(
    // 下拉的头部项,目前每一项,只能自定义显示的文字、图标、图标大小修改
    items: [
      GZXDropDownHeaderItem(_dropDownHeaderItemStrings[0]),
      GZXDropDownHeaderItem(_dropDownHeaderItemStrings[1]),
      GZXDropDownHeaderItem(_dropDownHeaderItemStrings[2]),
      GZXDropDownHeaderItem(_dropDownHeaderItemStrings[3], iconData: Icons.filter_frames, iconSize: 18),
    ],
    // GZXDropDownHeader对应第一父级Stack的key
    stackKey: _stackKey,
    // controller用于控制menu的显示或隐藏
    controller: _dropdownMenuController,
    // 当点击头部项的事件,在这里可以进行页面跳转或openEndDrawer
    onItemTap: (index) {
      if (index == 3) {
        _scaffoldKey.currentState.openEndDrawer();
        _dropdownMenuController.hide();
      }
    },
    // 头部的高度
    height: 40,
    // 头部背景颜色
    color: Colors.red,
    // 头部边框宽度
    borderWidth: 1,
    // 头部边框颜色
    borderColor: Color(0xFFeeede6),
    // 分割线高度
    dividerHeight: 20,
    // 分割线颜色
    dividerColor: Color(0xFFeeede6),
    // 文字样式
    style: TextStyle(color: Color(0xFF666666), fontSize: 13),
    // 下拉时文字样式
    dropDownStyle: TextStyle(
      fontSize: 13,
      color: Theme.of(context).primaryColor,
    ),
    // 图标大小
    iconSize: 20,
    // 图标颜色
    iconColor: Color(0xFFafada7),
    // 下拉时图标颜色
    iconDropDownColor: Theme.of(context).primaryColor,
  ),

GZXDropDownMenu #

  // 下拉菜单
  GZXDropDownMenu(
    // controller用于控制menu的显示或隐藏
    controller: _dropdownMenuController,
    // 下拉菜单显示或隐藏动画时长
    animationMilliseconds: 500,
    // 下拉菜单,高度自定义,你想显示什么就显示什么,完全由你决定,你只需要在选择后调用_dropdownMenuController.hide();即可
    menus: [
      GZXDropdownMenuBuilder(
          dropDownHeight: 40 * 8.0,
          dropDownWidget: _buildQuanChengWidget((selectValue) {
            _dropDownHeaderItemStrings[0] = selectValue;
            _dropdownMenuController.hide();
            setState(() {});
          })),
      GZXDropdownMenuBuilder(
          dropDownHeight: 40 * 8.0,
          dropDownWidget: _buildConditionListWidget(_brandSortConditions, (value) {
            _selectBrandSortCondition = value;
            _dropDownHeaderItemStrings[1] =
            _selectBrandSortCondition.name == '全部' ? '品牌' : _selectBrandSortCondition.name;
            _dropdownMenuController.hide();
            setState(() {});
          })),
      GZXDropdownMenuBuilder(
          dropDownHeight: 40.0 * _distanceSortConditions.length,
          dropDownWidget: _buildConditionListWidget(_distanceSortConditions, (value) {
            _dropDownHeaderItemStrings[2] = _selectDistanceSortCondition.name;
            _selectDistanceSortCondition = value;
            _dropdownMenuController.hide();
            setState(() {});
          })),
    ],
  )

[1.0.3] - [2019-08-06]

[1.0.2] - [2019-06-06]

  • update readme

[1.0.1] - [2019-06-06]

  • refactor code

[1.0.0] - [2019-06-03]

  • Custom dropdown header
  • Custom dropdown header item
  • Custom dropdown menu
  • Custom dropdown menu show animation time
  • Control dropdown menu show or hide

example/README.md

example #

A new Flutter application.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  gzx_dropdown_menu: ^1.0.3

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:gzx_dropdown_menu/gzx_dropdown_menu.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
85
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
85
Overall:
Weighted score of the above. [more]
89
Learn more about scoring.

We analyzed this package on Nov 15, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.0
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.6

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Fix lib/src/gzx_dropdown_header.dart. (-1 points)

Analysis of lib/src/gzx_dropdown_header.dart reported 2 hints:

line 6 col 7: This class (or a class which this class inherits from) is marked as '@immutable', but one or more of its instance fields are not final: GZXDropDownHeader.style, GZXDropDownHeader.dropDownStyle, GZXDropDownHeader.iconDropDownColor

line 51 col 10: The value of the field '_screenHeight' isn't used.

Fix lib/src/gzx_dropdown_menu.dart. (-0.50 points)

Analysis of lib/src/gzx_dropdown_menu.dart reported 1 hint:

line 83 col 3: The declaration '_hideDropDownItemWidget' isn't referenced.

Format lib/gzx_dropdown_menu.dart.

Run flutter format to format lib/gzx_dropdown_menu.dart.

Format lib/src/gzx_dropdown_menu_controller.dart.

Run flutter format to format lib/src/gzx_dropdown_menu_controller.dart.

Maintenance suggestions

The package description is too short. (-15 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.7 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test