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

套件詳情v0.1.1

common_utilities

一個 Dart 語言的通用工具套件,讓您的程式碼更快、更簡單、更乾淨。包含大量對 Dart 原始類型有用的函數(支援所有 Flutter 平台)

AndroidiOSWeb
近 30 天下載
63
喜歡數
39
Pub 分數
140

安裝套件

flutter pub add common_utilities

套件介紹

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

一個 Dart 工具套件,旨在透過為基本類型提供一組有用的函數來簡化開發。它提升了程式碼可讀性,減少樣板程式碼,並在所有 Flutter 平台(包括 Android、iOS 和 Web)上提高效率。此套件非常適合尋求使用乾淨、可重複使用的工具來簡化常見任務,並順暢整合到現有專案中的開發人員。

適用情境

  • 簡化字串與數字操作
  • 處理空安全操作
  • 高效格式化資料
  • 減少應用中的重複程式碼
  • 提升開發人員的生產力

主要特色

  • Dart 原語的豐富實用函數
  • 空值安全支援
  • 跨平台相容性
  • 輕量且易於整合
  • 文件完整且維護良好

適合對象

  • Flutter 開發人員尋找快速實用的輔助工具
  • 需要一致資料處理的專案
  • 致力於減少程式碼重複的團隊
  • 專注於程式碼潔淨與可維護性的開發者

使用建議

  • 如果導入了未使用的函數,可能會引入輕微開銷
  • 最適合需要頻繁執行實用操作的專案
  • 不適用於複雜業務邏輯
  • 需要仔細管理匯入以避免膨脹

原始 README

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

common_utilities

A Dart language Common Utility package, that makes your code faster,easier and cleaner. contains lots of useful functions for Dart primitive types (support all Flutter platforms)

Features

  • String : Over 30 useful String utility functions.

Todo (Next Versions)

  • Add Numbers (int, double, num, BigInt) utility functions.
  • Add Booleans (bool) utility functions.
  • Add Lists (List) utility functions.

Notes

version 0.1.1 Includes only String utils.

Usage

add this line to your pubspec.yaml :

    dependencies:
      common_utilities: ^0.1.1

or enter this to your command line:

    flutter pub add common_utilities

String Utils

Includes over 30 useful string functions such as :

  1. subStringBetween
  2. subStringsBetween
  3. subStringAfter
  4. subStringBefore
  5. insertAt
  6. removeAt
  7. insertAfter
  8. insertAfterEvery
  9. removeAfter
  10. removeBefore
  11. isNumericInt
  12. isNumericDouble
  13. isAlphabetic
  14. isUpperCase
  15. isAlphaNumeric
  16. isBlank
  17. isContainSpecialChar
  18. isValidCharacters
  19. convertEnglishNumberToPersian
  20. convertPersianNumberToEnglish
  21. convertToMoneyFormat
  22. countWords
  23. countLines
  24. reverse
  25. reverseWords
  26. removeBlankLines
  27. removeLinesThatContain
  28. isEmail
  29. convertToBase64
  30. convertBase64ToString
  31. convertToUTF8
  32. wrap
  33. isValidUrl

How To Use

Example for StringUtils :
import 'package:common_utilities/common_utilities.dart';

void main() {
  String yourStr = 'If you want something you have never had you must do something you have never done';

  String result = yourStr.stringUtils().subStringBetween('want', 'never');
  // print(result) =>  'something you have'

  List<String> result2 = yourStr.stringUtils().subStringsBetween('you', 'never');
  // print(result2) =>  ['something you have' , 'must do something you have']

  String result3 = yourStr.stringUtils().subStringAfter('something');
  // print(result3) =>  'you have never had you must do something you have never done'

  bool lastIndex = true; //This is optional & its false by default
  String result4 = yourStr.stringUtils().subStringAfter('something', lastIndex);
  // print(result4) =>  'you have never done'

  String str = CommonUtils.getRandomString(10);
  // print(str) =>  'btorklcvxw'

}

More Info

  • This package is equivalent of Common Utils library in Java, by this package there is no more need to write utils functions, just add it to your project and enjoy.
  • Feel free to make pull request to add your desire functions if its not included in the package functions list.

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。