搜索插件、代码仓与 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 项

源码仓库

使用此插件的项目

暂无相关数据。