ns_utils is a powerful Flutter utility library that simplifies and enhances your Flutter app development experience. It provides a collection of methods and extensions to streamline your code, making it more readable and efficient. Whether you need responsive design, date and time handling, map operations, string manipulation, or widget customization, ns_utils has got you covered.
- Open your project's
pubspec.yaml
file. - Add ns_utils as a dependency and replace
[version]
with the latest version:
dependencies:
flutter:
sdk: flutter
ns_utils: ^[version]
- Run
flutter pub get
to fetch the package.
import 'package:ns_utils/src.dart';
ns_utils offers a wide range of features to simplify your Flutter development process:
Learn more about it in the article Flutter -: KILL THE RED SCREEN OF DEATH.
Read about responsive app design in Flutter in Responsive App in Flutter.
Simplify your code by using these extensions:
- Replace lengthy
Navigator.of(context).push(...)
withcontext.push(...)
. - More intuitive methods like
context.replace(...)
,context.makeFirst(...)
, andcontext.pop(...)
are available. - Easily access device dimensions with
context.mq.sizeX.width
andcontext.mq.sizeX.height
. - Simplify focus management with
context.setFocus(focusNode: focusNode)
.
Enhance date and time handling with extensions like:
dayDifference
: Get the difference in days between a date and the current date.toServerFormat()
: Get an ISO-8601 formatted date string.isToday
,isYesterday
,isTomorrow
: Check if a date is today, yesterday, or tomorrow.tomorrow()
andyesterday()
: Get the next day or previous day.
Streamline operations on Map objects:
- Use methods like
getBool('key')
,getInt('key')
,getDouble('key')
,getString('key')
,getList('key')
, andgetMap('key')
to retrieve values with optional default values. - Convert a Map to a JSON string using
toJson()
. - Beautify Map output with
toPretty()
.
Manipulate lists easily with toJson()
, which converts a list to a JSON string.
Simplify string operations:
toMap()
: Parse a JSON string into a Map.toList()
: Parse a JSON string into a List.isEmptyOrNull
: Check if a string is null or empty.isNotBlank
: Check if a string is not null, not empty, and not just whitespace.toINT
andtoDOUBLE
: Parse a string as an int or double.asBool
: Convert a string into a boolean.
Enhance numeric operations with extensions like:
asBool
: Convert an integer into a boolean.- Fractional operations:
tenth
,fourth
,third
,half
,doubled
,tripled
.
Customize widgets with ease:
- Add tooltips and gestures to widgets without complex nesting.
- Utilize widgets like
Container
andSizedBox
with simplified notation. - Expect even more widget enhancements in future updates.
You can contribute to ns_utils in various ways:
- Propose new features or enhancements.
- Report bugs.
- Fix bugs.
- Participate in discussions and help with decision-making.
- Improve documentation.
- Send pull requests with your contributions.
A big thank you to all our contributors!