Giter Site home page Giter Site logo

fancy-extensions's Introduction

โœจ Dart Fancy Extensions Package

This package provides a collection of convenient Dart extensions for common operations, enhancing readability and improving code maintainability.

Features:

  • ifNullOrEmpty: Checks if a string is null or empty.
    String? name = null;
    if (name.ifNullOrEmpty('')) {
      print('Name is empty.');
    }
  • ifReturn: Executes a function and returns its result only if a condition is true.
    int age = 25;
    int? adultAge = age.ifReturn(age >= 18, null);
    print(adultAge); // Output: 25
  • let: Introduces a temporary variable within a code block, similar to let in other languages.
    String fullName = 'John Doe';
    List<String> parts = fullName.split(' ').let((parts) => parts.reversed.toList());
    print(parts); // Output: ['Doe', 'John']
  • elementAtOrNull: Safely retrieves an element from a list at a specific index, returning null if the index is out of bounds.
    List<int> numbers = [1, 2, 3];
    int thirdNumber = numbers.elementAtOrNull(2);
    print(thirdNumber); // Output: 3
  • capitalizeFirstLetter: Capitalizes the first letter of a string.
    String greeting = 'hello';
    String capitalizedGreeting = greeting.capitalizeFirstLetter;
    print(capitalizedGreeting); // Output: Hello

๐ŸŽ– Installation:

  1. Add the following dependency to your pubspec.yaml file:

    dependencies:
      fancy_extensions: ^0.0.3

    Replace fancy_extensions with the actual name of your package.

  2. Run pub get to install the package.

๐ŸŽฎ Usage:

Import the package in your Dart files:

import 'package:fancy_extensions/fancy_extensions.dart';

Then, use the extensions on your variables and data structures as demonstrated in the examples above.

๐Ÿ”ฅ Contributing:

We welcome contributions to this package! Please feel free to open issues or pull requests.

โญ๏ธ License:

This package is licensed under BSD 3-Clause License: BSD 3-Clause License.

fancy-extensions's People

Contributors

abdurahmon727 avatar

Stargazers

 avatar  avatar Asadbek Fayzulloev avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.