搜尋套件、儲存庫與 APP 分類

套件詳情v1.0.0

byte_flow

位元流是純 Dart、無依賴的程式庫,為清單和字串提供常見的實用功能。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
197
喜歡數
19
Pub 分數
130

安裝套件

flutter pub add byte_flow

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

Byte Flow 是一個輕量級、無依賴的 Dart 庫,提供列表和字串的基本實用功能。設計簡潔高效,為 Dart 核心類型增添便利方法,且不引入外部依賴。非常適合希望在多平台資料處理任務中實現乾淨高效程式碼改進的開發者。該庫持續維護且開源,便於自訂與貢獻。可透過 pub.dev 輕鬆整合至 Flutter 和 Dart 專案中。

適用情境

  • 字串操作工具
  • 列表轉換輔助工具
  • 應用程式中的資料預處理
  • 跨平台開發
  • 簡單、快速的操作
  • 程式碼可讀性增強

主要特色

  • 純 Dart 實現
  • 無外部依賴
  • 擴展核心 Dart 類型
  • 開源且由社群驅動
  • 輕量且高效
  • Platform-agnostic

適合對象

  • Flutter 開發者
  • 純 Dart 項目
  • 小型到中型應用
  • 重視最小依賴項的團隊
  • 重視程式碼乾淨、易讀的開發者
  • 需要基本資料工具的專案

使用建議

  • 僅限清單和字串操作
  • 不適用於複雜的資料結構
  • 可能需要額外的邏輯來處理進階用例
  • 適用於簡單、重複性的任務
  • 不包含進階演算法
  • 補充而非取代功能完整的函式庫

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Byte flow

Build Status

Byte flow is a pure dart , dependency less library that provides common utility functions for lists and strings .

Contents

Install

dependencies:
  byte_flow: ^1.0.0

After this run flutter pub get Then import the library

import 'package:byte_flow/byte_flow.dart';

Functions

Byte flow contains helpful utility functions for lists and strings but it's main target is to provide developers rich set of list utilites .

Array

First import the library like this

import 'package:byte_flow/byte_flow.dart' as _;

_.chunk(List list, [int size = 1])

Creates an list of elements split into groups the length of size. If list can't be split evenly, the final chunk will be the remaining elements.

Example

_.chunk(['a', 'b', 'c', 'd'], 2);
// Returns ['a', 'b'],['c', 'd']

_.chunk(['a', 'b', 'c', 'd'], 3)
// Returns ['a', 'b', 'c'],['d']

_.slice(List list, [int start = 0, int end])

Creates a slice of list from start up to, but not including, end.

Example

_.slice([1, 2, 3, 4], 2);
// Returns [3, 4]

_.compact(List list)

Creates an list with all falsey values removed. The values false, null,0, "", and NaN are falsey.

Example

_.compact([0, 1, false, 2, '', 3]);
// Returns [1, 2, 3]

_.compact([1, 2, 'some data', 2, '', 3, false, null]);
// Returns [1, 2, 'some data', 2, 3]

_.drop(List list, [int n = 1])

Creates a slice of list with n elements dropped from the beginning.

Example

_.drop([1, 2, 3]);
// Returns [2,3]

_.drop([1, 2, 3], 2);
// Returns [3]

_.drop([1, 2, 3], 5);
// Returns []

_.drop([1, 2, 3], 0);
// Returns [1, 2, 3]

_.dropRight(List list, [int n = 1])

Creates a slice of list with n elements dropRightped from the beginning.

Example

_.dropRight([1, 2, 3])
// Returns [1,2]
_.dropRight([1, 2, 3], 2)
// Returns [1]
_.dropRight([1, 2, 3], 5)
// Returns []
_.dropRight([1, 2, 3], 0)
// Returns [1, 2, 3]

_.fill(List list, dynamic value, [int start = 0, int end])

Fills elements of list with value from start up to, but not including, end.

Example

_.fill(List(3), 4);
// Returns [4, 4, 4]

_.findIndex(List list, dynamic element)

This method uses dart's default List.indexOf()

Example

_.findIndex(["Jack", "Yash", "Adib", "Alex"], "Adib");
// Returns 2

_.findLastIndex(List list, dynamic element)

This method finds the item in the list from right / last using dart's List.indexOf() method

Example

_.findLastIndex(["Jack", "Yash", "Adib", "Adib"], "Adib");
// Returns 0

_.head(List list)

Finds the first element in the list Uses dart's List.first property

Example

_.head(["Dart", "Javascript", "Swift"]);
// Returns "Dart"

_.flatten(List list)

Flatten a list , Credit goes to Justin Fagnani

Example

_.flatten([
  [1, 2, 3],
  ['a', 'b', 'c'],
  [true, false, true]
]);
// Returns [1, 2, 3, 'a', 'b', 'c', true, false, true]

_.pairs(List pairs)

This method returns an map composed from key-value pairs.

Example

_.pairs([
  ['a', 1],
  ['b', 2]
]);
// Returns {'a': 1, 'b': 2}

`_.initial(List list)```

Gets all but the last element of list.

Example

_.initial([1, 2, 3]);
// Returns [1, 2]

_.initial([1, 2, 3, 'a', 'b', 'c']);
// Returns [1, 2, 3, 'a', 'b']

_.map(List list, Function(dynamic element, int index, List list) iteratee)

Creates an list of values by running each element of list thru iteratee. The iteratee is invoked with three arguments: (value, index, list).

Example

square(n, index, list) {
  return n*n;
}
_.map([4, 8], square);
// Returns [16, 64]

_.map([4, 8], (n, index, list) {
  return n * 0;
});
// Returns [0, 0]

_.intersect(List<List> arrays)

Creates an list of unique values that are included in all given arrays

Example

final lists = [
  [1, 2, 3],
  [2, 4, 5],
  [2, 8, 9]
];
_.intersect(lists);
// Returns [2]

_.join(List list, [String separator = ','])

Converts all elements in list into a string separated by separator. Uses dart's List.join()

Example

_.join(['a', 'b', 'c'], '~');
// Returns 'a~b~c'

_.last(List list)

Gets the last element of list. Uses dart's List.last property

Example

_.last(["Dart", "Javascript", "Swift"]);
// Returns "Swift"

_.nth(List list, int n)

Gets the element at index n of list. If n is negative, the nth element from the end is returned.

Example

_.nth(['a', 'b', 'c', 'd'], 2);
// Returns 'c'

_.nth(['a', 'b', 'c', 'd'], -1);
// Returns 'd'

_.sortedIndex(List list, dynamic value)

Uses a binary search to determine the lowest index at which value should be inserted into list in order to maintain its sort order. Returns the index at which value should be inserted into list.

Example

_.sortedIndex([30, 50], 60);
// Returns 2

_.sortedIndex([30, 50], 40);
// Returns 1

_.sortedIndex([30, 50], 30);
// Returns 0

_.tail(List list)

Gets all but the first element of list.

Example

_.tail([1, 2, 3]);
// Returns [2, 3]

_.take(List list, [int n = 1])

Creates a slice of list with n elements taken from the beginning. Uses dart's native List.take(n) method

Example

_.take([1, 2, 3], 2);
// Returns [1, 2]

_.takeRight(List list, [int n = 1])

Creates a slice of list with n elements taken from the end.

Example

takeRight([1, 2, 3])
// => [3]
takeRight([1, 2, 3], 2)
// => [2, 3]
takeRight([1, 2, 3], 5)
// => [1, 2, 3]
takeRight([1, 2, 3], 0)
// => []

_.union(List<List> arrays)

Creates an list of unique values, in order

Example

_.union([
  [2],
  [1, 2]
]);

// Returns [2, 1]

_.unzip(List list)

This method Returns the new list of regrouped elements

Example

_.unzip([['a', 1, true], ['b', 2, false]]);
// Returns [['a', 'b'], [1, 2], [true, false]]

_.zip(List a, List b)

Zips two arrays , Credit

Example

_.zip(['a', 'b', 'c'], [1, 2, 3]);
// Returns [['a', 1],['b', 2],['c', 3]]

_.duplicate(List list)

Find duplicate items in an list .

Example

_.duplicate([10, 12, 9, 21, 1, 2, 10]);
// Returns [10]

String

Byte flow libraries string utility collection is poor but still under development . The following functions are stable

_.capitalize(String text)

Capitalizes the given string

Example

_.capitalize("hello world !");
// Returns "Hello world !"

TODO

  • [x] Null safety
  • [ ] Extension support

所屬分類

原始碼儲存庫

使用此套件的專案

暫無相關資料。