nullx_object - dart nullability with confidence


Coverage Dart CI Very Good Workflow pub.flutter-io.cn CodeFactor Codacy Badge Codecov Codacy Badge License: MIT


nullx_object is a dart toolkit that enhances handling of nullable types, providing utilities for null-checking, navigating nullable structures, and robust error handling, for cleaner and more resilient code.

Features

  • Provides utilities for null-checking
  • Helps in navigating nullable structures
  • Nullable types extensions

Getting started 🎉

To use this package, add nullx_object as a dependency in your pubspec.yaml file.

dependencies:
  nullx_object: ^latest_version

Here is a simple example of how to use nullx_object:

import 'package:nullx_object/nullx_object.dart';

void main() {
  const Object? nullObject = null;
  // ignore: unnecessary_nullable_for_final_variable_declarations
  const Object? nullableStringObject = 'Hello';
  // ignore: avoid_print
  print(nullObject.isNull); // true
  // ignore: avoid_print
  print(nullObject.isNotNull); // false
  final result =
      nullableStringObject.mapIfNotNull((it) => (it as String).length);
  // ignore: avoid_print
  print(result); // 5
}

Contributing

Contributions are welcome! Please read the contributing guide to learn how to contribute to the project and set up a development environment.

License

Copyright 2024 Oleksii Shtanko

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Libraries

nullx_object