indexed_list_view

所属分类:Flutter开发
开发工具:Dart
文件大小:92KB
下载次数:0
上传日期:2022-04-17 01:50:26
上 传 者sh-1993
说明:  Flutter包:类似于ListView,但允许您通过索引以编程方式跳到任何项。
(Flutter package: Similar to a ListView, but lets you programmatically jump to any item, by index.)

文件列表:
CHANGELOG.md (876, 2022-04-17)
LICENSE (1272, 2022-04-17)
analysis_options.yaml (37231, 2022-04-17)
example (0, 2022-04-17)
example\.metadata (305, 2022-04-17)
example\android (0, 2022-04-17)
example\android\app (0, 2022-04-17)
example\android\app\build.gradle (1670, 2022-04-17)
example\android\app\src (0, 2022-04-17)
example\android\app\src\debug (0, 2022-04-17)
example\android\app\src\debug\AndroidManifest.xml (327, 2022-04-17)
example\android\app\src\main (0, 2022-04-17)
example\android\app\src\main\AndroidManifest.xml (1702, 2022-04-17)
example\android\app\src\main\java (0, 2022-04-17)
example\android\app\src\main\java\com (0, 2022-04-17)
example\android\app\src\main\java\com\example (0, 2022-04-17)
example\android\app\src\main\java\com\example\example (0, 2022-04-17)
example\android\app\src\main\java\com\example\example\MainActivity.java (364, 2022-04-17)
example\android\app\src\main\res (0, 2022-04-17)
example\android\app\src\main\res\drawable (0, 2022-04-17)
example\android\app\src\main\res\drawable\launch_background.xml (434, 2022-04-17)
example\android\app\src\main\res\mipmap-hdpi (0, 2022-04-17)
example\android\app\src\main\res\mipmap-hdpi\ic_launcher.png (544, 2022-04-17)
example\android\app\src\main\res\mipmap-mdpi (0, 2022-04-17)
example\android\app\src\main\res\mipmap-mdpi\ic_launcher.png (442, 2022-04-17)
example\android\app\src\main\res\mipmap-xhdpi (0, 2022-04-17)
example\android\app\src\main\res\mipmap-xhdpi\ic_launcher.png (721, 2022-04-17)
example\android\app\src\main\res\mipmap-xxhdpi (0, 2022-04-17)
example\android\app\src\main\res\mipmap-xxhdpi\ic_launcher.png (1031, 2022-04-17)
example\android\app\src\main\res\mipmap-xxxhdpi (0, 2022-04-17)
example\android\app\src\main\res\mipmap-xxxhdpi\ic_launcher.png (1443, 2022-04-17)
example\android\app\src\main\res\values (0, 2022-04-17)
example\android\app\src\main\res\values\styles.xml (361, 2022-04-17)
example\android\app\src\profile (0, 2022-04-17)
example\android\app\src\profile\AndroidManifest.xml (327, 2022-04-17)
example\android\build.gradle (470, 2022-04-17)
... ...

[![pub package](https://img.shields.io/pub/v/indexed_list_view.svg)](https://pub.dartlang.org/packages/indexed_list_view) # indexed_list_view Similar to a ListView, but lets you **programmatically jump to any item**, by index. The index jump happens **instantly**, no matter if you have millions of items. Limitation: The list is always **_infinite_** both to positive and negative indexes. In other words, it can be scrolled indefinitely both to the top and to the bottom. You can define index bounds by giving it a `minItemCount` and `maxItemCount`, but this will not prevent the list from scrolling indefinitely. When showing items out of the index bounds, or when your `itemBuilder` returns `null`, it will ask the `emptyItemBuilder` to create an "empty" item to be displayed instead. As default, this will return empty containers. ## Usage ### Import the package Add indexed_list_view [as a dependency](https://pub.dartlang.org/packages/indexed_list_view#-installing-tab-) in your `pubspec.yaml` file, and then import it: import 'package:indexed_list_view/indexed_list_view.dart'; ### Use the package First, create an indexed scroll controller: var controller = IndexedScrollController(); Optionally, you may setup an initial index and/or initial scroll offset: var controller = IndexedScrollController( initialIndex: 75, initialScrollOffset : 30.0); Then, create the indexed list view, and pass it the controller: IndexedListView.builder( controller: controller, itemBuilder: itemBuilder); There is also the separated constructor, same as `ListView.separated`: IndexedListView.separated( controller: controller, itemBuilder: itemBuilder, separatorBuilder: separatorBuilder); To jump, use the controller methods like `jumpToIndex` : controller.jumpToIndex(10000); ## Details The IndexedScrollController has not only an `offset` in pixels, but also an `origin-index` that indicates which item is considered to be at the offset position `0.0`. So there are two ways for you to move the list programmatically: You can change only the `offset`, or else change the `originIndex` and the `offset` at the same time. To change the `originIndex` you make an "index jump". This jump is cheap, since it doesn't need to build all widgets between the old and new positions. It will just change the origin. If you want to move the list programmatically you must create a scroll controller of type `IndexedScrollController` and pass it in the list constructor. However, if all you need is an infinite list without jumps, then there is no need to even create a controller. You move the list programmatically by calling the controller methods. ## Controller Methods 1. `jumpToIndex(index)` The is the most common method for you to use. It jumps the origin-index to the given index, and the scroll-position to 0.0. 2. `jumpToIndexAndOffset(index, offset)` Jumps the origin-index to the given index, and the scroll-position to offset, without animation. 3. `animateToIndex(index)` If the current origin-index is already the same as the given index, animates the position from its current value to the offset position relative to the origin-index. However, if the current origin-index is different from the given index, this will jump to the new index, without any animation. In general, there are never animations when the index changes. 2. `animateToIndexAndOffset(index, offset)` Same as `animateToIndex()` but also lets you specify the new offset. 4. `jumpTo(offset)` Goes to origin-index "0", and then jumps the scroll position from its current value to the given offset, without animation. 4. `animateTo(offset)` If the current origin-index is already "0", animates the position from its current value to the offset position. However, if the current origin-index is different from "0", this will jump to index "0" and the given offset, without any animation. In general, there are never animations when the index changes. 5. `jumpToWithSameOriginIndex(offset)` Jumps the offset, relative to the current origin-index. 6. `animateToWithSameOriginIndex(offset)` Animates the offset, relative to the current origin-index. 7. `jumpToRelative(offset)` Jumps the offset, adding or subtracting from the current offset. It keeps the same origin-index. 8. `animateToRelative(offset)` Animates the offset, adding or subtracting from the current offset. It keeps the same origin-index. Don't forget to check the [example tab](https://pub.dartlang.org/packages/indexed_list_view#-example-tab-). It shows an infinite list of items of different heights, and you may tap buttons to run some of the methods explained above. ******** Hopefully this widget will become obsolete when Flutter's original ListView allows for negative indexes and for indexed jumps. See: https://github.com/flutter/flutter/issues/12319 *This package got some ideas from [Collin Jackson's code in StackOverflow](https://stackoverflow.com/questions/44468337/how-can-i-make-a-scrollable-wrapping-view-with-flutter) , and uses lots of code from [Simon Lightfoot's infinite_listview](https://pub.dev/packages/infinite_listview).* *The Flutter packages I've authored:* * async_redux * fast_immutable_collections * provider_for_redux * i18n_extension * align_positioned * network_to_file_image * image_pixels * matrix4_transform * back_button_interceptor * indexed_list_view * animated_size_and_fade * assorted_layout_widgets * weak_map * themed * bdd_framework *My Medium Articles:* * Async Redux: Flutter’s non-boilerplate version of Redux ( versions: Portugues) * i18n_extension ( versions: Portugues) * Flutter: The Advanced Layout Rule Even Beginners Must Know ( versions: русскии) * The New Way to create Themes in your Flutter App *My article in the official Flutter documentation*: * Understanding constraints ---
_Marcelo Glasberg:_
_https://github.com/marcglasberg_
_https://linkedin.com/in/marcglasberg/_
_https://twitter.com/glasbergmarcelo_
_https://stackoverflow.com/users/3411681/marcg_
_https://medium.com/@marcglasberg_

近期下载者

相关文件


收藏者