搜索插件、代码仓与 APP 分类

smooth_sort 封面
插件详情v2.0.1

smooth_sort

一个用于添加精美且自定义排序动画的 Flutter 包。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
106
喜欢数
32
Pub 分数
160

安装插件

flutter pub add smooth_sort

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

Smooth Sort 是一个 Flutter 包,可为列表提供流畅且可自定义的排序动画。它通过在列表项重新排序时提供流畅的视觉过渡来提升用户体验。专为寻求精致 UI 交互的开发者设计,支持多种动画类型,并可轻松集成到针对 Android、iOS、Web、macOS、Windows 和 Linux 的应用中。该包注重性能和简洁性,使开发者无需复杂实现即可添加动态排序效果。适用于仪表板、任务列表以及任何频繁进行列表重新排序的应用。

适合场景

  • 动画列表重新排序
  • 任务管理应用
  • 仪表板小部件
  • 可排序的数据表
  • 用户驱动的列表排序
  • 交互式 UI 组件

主要特点

  • 可自定义的排序动画
  • 跨平台支持
  • 与 ListView 的轻松集成
  • 性能优化的渲染
  • 可配置的动画曲线
  • 支持拖放场景

适合对象

  • 希望实现动画列表交互的开发者
  • 频繁更新列表的应用
  • 以用户界面为中心的应用程序
  • Flutter 初学者探索动画
  • 需要流畅过渡的项目

使用建议

  • 在非常大的列表上可能会影响性能
  • 需要仔细处理状态管理
  • 仅限列表项重新排序
  • 不适用于非交互式排序
  • 动画复杂度可能影响响应速度

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。


In today's world, developer's use now and then sorting in their mobile applications. For such developer's, Smooth Sort can become a useful package which provides wonderful and custom animation while sorting a list instead of reloading the app.

Explore how to use SmoothSort in your Flutter app through this medium blog.

Table of Contents

Installing

1. Depend on it

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

dependencies:
  smooth_sort: ^2.0.1
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:smooth_sort/smooth_sort.dart';

Demo

Flip Vertically
animationType: flipVertically

Fade
animationType: fade

Slide Right
animationType: slideRight

Flip Horizontally
animationType: flipHorizontally

Scale
animationType: scale

Slide Left
animationType: slideLeft

Reverse Flip Vertically
animationType: reverseFlipVertically

Reverse Flip Horizontally
animationType: reverseFlipHorizontally

Example in Medium blog

In the medium blog as well as the example app, I have implemented this animation for the shopping app for sorting the products through price using the Smooth Sort package.

Scale Animation

Usage

For adding the SmoothSort in your Flutter app, you have to simply provide the options for ListView or GridView with the list of the widgets to be displayed in the list/grid with the another list of their corresponding itemIds.

For example: First create the object for SmoothSort

SmoothSort smoothSort = SmoothSort(
	listType: 'list',	 // specify the listType i.e. list or grid
	ascendant: true,	// sort ascending or descending
	itemList: [  
	  Container(  
	    color: Colors.red,  
	    alignment: Alignment.center,  
		child: Text(  
		    "A",  
	        style: TextStyle(fontSize: 150.0),  
		    ),  
	  ),  
	  Container(  
	    color: Colors.blueAccent,  
	    alignment: Alignment.center,  
	    child: Text(  
		    "B",  
	        style: TextStyle(fontSize: 150.0),  
			),  
	  ),  
	  Container(  
	    color: Colors.yellowAccent,  
	    alignment: Alignment.center,  
	    child: Text(  
		    "C",  
	        style: TextStyle(fontSize: 150.0),  
			),  
	  ),   
	],					// specify the list of widgets for the ListView/GridView
	itemIdList: [1, 2, 0],		// specify the corresponding ids for widgets	
	animationType: 'cardScale'	// specify the type of animation you want
);

Whenever you want to add the list or grid, just add the above widget as follows:

Column(  
  children: <Widget>[  
    smoothSort	// just add the SmoothSort object
  ],
),

After this, just call the smoothSort.onPress() method to start the animation for sorting the list/grid just like this:

RaisedButton(  
  child: Text("Sort"),  
  onPressed: () {  
    smoothSort.onPress();	// just call the onPress method
  },  
)

For more info, please refer to the main.dart in example.

Documentation

SmoothSort Class
Dart attribute Datatype Description Default Value
listType String Specifies the type of list i.e. list/grid. list
animationType String Specifies the type of animation required to sort the list/grid. flipVertically
itemList List<Widget> The list of widgets which is to be sorted. @required
itemIdList List<int> This list contains the ids for the corresponding widgets needed for the sorting of widgets. @required
gridCrossAxisCount int The number of grids in a single row in GridView. 2
ascendant bool Sort ascending or descending true

For help on editing package code, view the flutter documentation.

Algorithm

The algorithm used to build this project is as follows:

I have sorted the ListView or GridView with single TextView by using the default sort function by Dart language. On clicking of the sort button, I have provided different animations to the ListView or GridView according to the animation described by the user.

For more info, please refer to the smooth_sort.dart.

Bugs or Requests

If you encounter any problems feel free to open an issue. If you feel the library is
missing a feature, please raise a ticket on Github and I'll look into it.
Pull request are also welcome.

Contributors

Thanks goes to these awesome people! :blush:


Giulliano Albrecht

Michael Dudek

License

SmoothSort is licensed under MIT license. View license.

所属分类

源码仓库

使用此插件的项目

暂无相关数据。