FLUTTER ECOSYSTEM

TNorbury/flutter_expandable_sliver_list

Flutter 小部件,允许用户创建可展开的滑动列表。在自定义滚动视图中展开和折叠项目列表!

flutter_expandable_sliver_list 项目封面
Stars
7
Forks
6
最近推送(UTC)
2024年4月6日
项目状态
未归档
Tyler Norbury GitHub avatar
GITHUB User

Tyler Norbury ↗

Head of Mobile Development at @vakaros

@vakarosUK
语言Dart

技术话题

此仓库发布的插件

使用的依赖

依赖清单 3 项
  • flutter{"sdk":"flutter"}
  • flutter_lints开发依赖^2.0.1
  • flutter_test开发依赖{"sdk":"flutter"}

原始 README

以下为英文项目原文快照,最新内容请访问 GitHub。

展开 / 收起项目 README

expandable_sliver_list

pub package flutter_tests codecov style: flutter lints License: MIT

A Flutter widget which creates a Sliver List that you can then either expand or collapse, in order to show or hide the contents of the list.

https://raw.githubusercontent.com/TNorbury/flutter_expandable_sliver_list/master/readme_assets/example.gif

Getting Started

Installing

In your Flutter project, add the package to your dependencies

flutter pub add expandable_sliver_list

or

dependencies:
  ...
  expandable_sliver_list: ^4.1.0
  ...
Usage Example

A complete example on how to use this widget can be found in the example directory. But the basics are:

Import the package

import 'package:expandable_sliver_list/expandable_sliver_list.dart';

Create a controller and a list of items to display

ExpandableSliverListController controller = ExpandableSliverListController();

List<int> items = [1, 2, 3, 4, 5];

Create the widget

ExpandableSliverList<int>(
  initialItems: items,
  controller: controller,
  builder: (context, item, index) {
    return ListTile(
      title: Text(item.toString()),
    );
  },
)

Now you can use the controller to expand or collapse the list

controller.collapse();
controller.expand();

Or to add items to the list

controller.insertItem(54, 2);
controller.removeItem(4);