搜尋套件、儲存庫與 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.

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。