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

screwdriver 封面
套件詳情v5.12.0

screwdriver

一個 Dart 套件,旨在提供有用的擴展和輔助函數,以簡化和加速開發。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
1030
喜歡數
114
Pub 分數
160

安裝套件

flutter pub add screwdriver

套件介紹

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

Screwdriver 是一個 Dart 套件,提供一組有用的擴展和輔助函數,以簡化並加速跨多個平台的開發。它提供了常用任務(如字串操作、日期處理和空值安全性)的實用方法,減少冗餘程式碼。此套件以提升開發者生產力為設計目標,增強了 Flutter 和 Dart 項目的可讀性與一致性。該套件支援 Android、iOS、Web、macOS、Windows 與 Linux,適用於跨平台應用。

適用情境

  • 快速的字串和日期工具
  • 減少重複程式碼
  • 跨平台開發
  • 增強空安全
  • 提升程式碼可讀性
  • 加速原型開發

主要特色

  • 豐富的 Dart 擴展集
  • 空安全的實用函數
  • 跨平台相容性
  • 最小依賴開銷
  • 透過 pub 實現輕鬆整合
  • 文件完整的輔助工具

適合對象

  • 尋求生產力提升的Flutter開發者
  • 致力於標準化實用程式碼的團隊
  • 需要快速開發的項目
  • 僅 Dart 或跨平台應用
  • 重視簡潔明瞭語法的開發者

使用建議

  • 若跨團隊使用,可能會引入細微的 API 變更
  • 僅限於實用功能增強,而非完整框架
  • 升級版本時需仔細審查
  • 不適合複雜的業務邏輯
  • 最好與已建立的編碼標準搭配使用

原始 README

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

banner

Screwdriver

A dart package aiming to provide useful extensions and helper functions to ease and speed up development.

Tests Code Quality Codecov Pub Version Docs

  • 📋 Well Documented
  • ⚔️ Fully Tested
  • 👌 Follows Code Quality Guidelines
  • 🦾 Production Ready
  • collection included for extra extensions.

Stats

Check out EXTENSIONS.md for a complete list of all the available extensions.

Extensions:                    322
Extension Types:               4
Helper Classes:                5
Helper Functions & Getters:    29
Typedefs:                      10
Mixins:                        2

Last Updated: Fri, Aug 28, 2026 - 04:14 PM

Stats auto generated using Github Workflow.


To checkout all the available extensions, helper functions & classes, see documentation.

Installation

  1. Add as a dependency in your project's pub spec.yaml.
dependencies:
  screwdriver: <latest_version>

Note: Screwdriver exports collection package as well. So, you don't need to add collection as a dependency in your project.

  1. Import library into your code.
import 'package:screwdriver/screwdriver.dart';
  1. Use this import for using IO extensions.
import 'package:screwdriver/screwdriver_io.dart';

A Glimpse of Screwdriver

String
'hello'.capitalized; // Hello
'   '.isBlankl // true;
'45'.toIntOrNull(); // 45
'html'.wrap('<','>'); // <html>
'1010111010001'.isBinary; // true
'test@example.com'.isEmail; // true
'abcd'.reversed; // dcba
'This is a test'.words; // ['this', 'is', 'a', 'test']
'{"name":"John"}'.parseJson(); // map: {name:John}
'#hello'.removePrefix('#'); // hello
Map
final Map<String, dynamic> map = {
  'name': 'John',
  'age': 24,
};

for(final (key, value) in map.records) {
  print('$key: $value');
}
Int
20.isDivisibleBy(5); // true
0.asBool; // false
6.twoDigits; // '06'
2020.isLeapYear; // true
10.repeat((count) => print(count));
DateTime & Duration
now().isMonday;
final DateTime fiveDaysAgo = 5.daysAgo;
final Duration nineMinutes = 9.minutes;
45.minutes.isInHours; // false
15.daysAgo < 5.days.ago; // true
20.minutes.ago >= 50.minutes.ago; // true
now().previousDay; // yesterday
10.days.ago.isBetween(15.days.ago, now()); // true
Double and Bool
randomDouble(max: 50); // random double value between 0 and 50
56.0.isWhole; // true
true.toggled; // false
false.toInt(); // 0

Scope Functions
final User user = User(name: 'John').apply((user){
  user.age = 24;
  user.email = 'john@doe.com';
});
final String age = user.run((u)=> (u.age + 20).toString());
Collections
users << User(name: 'John'); // appends user to users list
users.firstOrNull;
users.drop(5);
users.takeLast(3);
user.all((u) => u.age > 18); // returns bool
cars.groupBy((car) => car.color);
cars.count((car) => car.isPorsche);
cars.random();
cars.maxBy((car) => car.price);
cars.intersect(otherCars);
{'name': 'John'} << Pair('email','john@doe.com');
Future
postDelayed(2000,(){
  print('after 2 seconds');
});
IO
file.onModified(() => print('file modified'));
file.clear(); // flushes all the data of file
file.isEmpty;
file.appendString('hello');
file << 'some text';
file1 + file2; // appends file2 content at the end of file1
Some More
check(divider != 0);
runCaching((){
  count / 0;
});
TODO('find a way to implement this properly'); // throws UnimplementedError on invocation
Triple(45,true, 'Hello World');
user.takeIf((u) => u.age > 18)?.allowAccess();
person.takeUnless((p) => p > 18)?.areTeenagers();
final DateTime date = tomorrow;
yesterday.isInDecember;

Check out EXTENSIONS.md for a complete list of all the available extensions.

Checkout documentation for more details.

Features and bugs

Please file feature requests and bugs at the issue tracker.

Liked Screwdriver?

Show some love and support by starring the repository.

Or You can

Buy Me A Coffee

License

Copyright (c) 2020, Birju Vachhani
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice,
   this list of conditions and the following disclaimer in the documentation
   and/or other materials provided with the distribution.

3. Neither the name of the copyright holder nor the names of its
   contributors may be used to endorse or promote products derived from
   this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

所屬分類

依賴

依賴清單 7 項

原始碼儲存庫

使用此套件的專案

暫無相關資料。