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

插件详情v4.2.0

strings

大量字符串函数,旨在扩展String类,同时为处理可空字符串提供更安全的方法。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
15.7万
喜欢数
58
Pub 分数
160

安装插件

flutter pub add strings

插件介绍

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

strings 包提供了一套丰富的实用函数,扩展了 Dart String 类,为处理非空和可为空的字符串提供了更安全、更便捷的方法。该包通过支持空安全操作增强了字符串操作,降低了运行时错误的风险。该包旨在简化常见的文本处理任务,如修剪、分割、验证和转换字符串,同时保持代码简洁易读。非常适合希望在多个平台上改进字符串处理的开发者。

适合场景

  • 字符串验证
  • 空安全的字符串操作
  • 文本格式化
  • 数据解析
  • 输入净化
  • 国际化支持

主要特点

  • 扩展 String 类以添加额外方法
  • 空安全工具
  • 全面的字符串操作
  • 跨平台兼容性
  • 通过 pub 实现轻松集成
  • 文档齐全的 API

适合对象

  • Web和移动应用开发
  • 表单输入处理
  • API 数据处理
  • 文本转换工作流
  • 注重代码安全的开发者

使用建议

  • 需要理解空安全
  • 可能为简单情况增加轻微开销
  • 仅限字符串专用工具
  • 不适用于复杂的正则表达式或模式匹配
  • 最适合已经使用空安全的项目

原始 README

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

The Strings package is an evolution of the work originally produced by Andrew Mezoni.

The purpose of the Strings package is to provide:

  • a collection of useful String functions to complement the core String class.
  • where viable, directly extend the String class with methods such as String.right, String.left...
  • provide a safer environment when working with nullable Strings (String?)
  • wrappers for each of the core String methods which are safe to use with a nullable String?.

A core objective of the Strings package is to never 'throw' or return an error but to make a best effort to process the passed data.

// passing null works too.
Strings.right(null, 4, pad: Pad.left);
 -> '    '

// pass a short string and we can pad it (or not).
Strings.right('one', 4, pad: Pad.left);
 -> ' one'

The Strings package also includes a number of methods exposed as extensions to the core Dart String class:

'a normal string'.right(4);
-> 'a no'

See the full list

The Strings package incudes over 50 functions.

You can see the full list including examples at:

strings.onepub.dev

Contributing:

The strings package is hosted on github at: github.com/onepub-dev/strings

Contributions are welcomed.

Sponser

The strings package is sponsored by OnePub - the private Dart repository SaaS.

onepub.dev

OnePub Logo

所属分类

依赖

依赖清单 2 项

源码仓库

使用此插件的项目