azlistview_ce
A Flutter list grouped by tag (for example by first letter), with an index bar on the side. Dragging or tapping the bar jumps straight to the first item of a tag, and the bar follows the tag at the top while you scroll.
This is a maintained successor of azlistview, which has not been updated since 2.0.0 (2022) and depends on the archived scrollable_positioned_list. It is rewritten for current Flutter on top of scrollable_positioned_list_plus. Bada Labs uses it in its dictionary apps.
Why this package
- Exact jumps. It jumps by item index, so the first item of a tag lands at the top even when rows have different heights and the group has never been built. Lists that jump by an estimated scroll offset can land far from the target in that case.
- Plain models. Pass any item type and a
tagOffunction. Nothing needs to extend a base class or carry list state. - Maintained foundation. No dependency on archived packages, and only
package:flutter/widgets.dart.
Usage
IndexedListView<Word>(
items: words, // sorted so that words with the same tag are adjacent
tagOf: (word) => word.initial,
itemBuilder: (context, word, isFirstOfTag) => Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (isFirstOfTag) SectionHeader(word.initial),
WordTile(word),
],
),
)
Styling the index bar
IndexedListView<Word>(
// ...
indexBarStyle: const IndexBarStyle(
width: 30,
itemHeight: 16,
textStyle: TextStyle(fontSize: 12, color: Color(0xFF666666)),
selectedTextStyle: TextStyle(fontSize: 12, color: Color(0xFFFFFFFF)),
selectedItemDecoration: BoxDecoration(
shape: BoxShape.circle,
color: Color(0xFF2196F3),
),
),
hintBuilder: (context, tag) => MyBubble(tag), // shown while dragging
)
The index bar shows the tags that exist in items, in the order they appear.
Migrating from azlistview
azlistview |
azlistview_ce |
|---|---|
class Word extends ISuspensionBean + getSuspensionTag() |
any class, plus tagOf: (word) => ... |
SuspensionUtil.setShowSuspensionStatus(items) and item.isShowSuspension |
isFirstOfTag argument of itemBuilder |
SuspensionUtil.getTagIndexList(items) as indexBarData |
computed from items |
IndexBarOptions(textStyle, selectTextStyle, selectItemDecoration) |
IndexBarStyle(textStyle, selectedTextStyle, selectedItemDecoration) |
indexHintBuilder |
hintBuilder |
Sorting stays your responsibility, as before. Sticky suspension headers (susItemBuilder) are not provided; build the header inside your row when isFirstOfTag is true.
Scope
This package fixes bugs and keeps up with Flutter changes. New features are considered conservatively to keep it small and dependable.
Credits
Inspired by and replacing azlistview by Flutter中文网, under the BSD 3-Clause license. Maintained by Bada Labs.
Libraries
- azlistview_ce
- A list grouped by tag with a draggable index bar that jumps exactly to
each group. A maintained successor of
azlistview.