Git Product home page Git Product logo

supercharged's Introduction

⚡️ Supercharged

Pub Tests

Supercharged brings all the comfort features from languages like Kotlin to all Flutter developers.

  • 💪 fully tested
  • 📝 well documented
  • 💼 enterprise-ready

⛏️ Getting started

Add the dependency supercharged: ^1.0.0 to your project and start using Supercharged everywhere:

import 'package:supercharged/supercharged.dart';

For more details have a look at the install tab.

🌞 Highlights

Transform any String to colors

"#ff00ff".toColor(); // painless hex to color
"red".toColor(); // supports all web color names

Helpful substring functions:

"mode:production".allAfter(":"); // "production"
"<html>".allBetween("<", ">"); // "html"`
"flutter is cool".allBefore(" is"); // "flutter"

Parse user input:

"2.1".toDouble(); // 2.1
"42".toInt(); // 

Effortless aggregation for Iterable<int> and Iterable<double>:

[1, 2, 3].sum(); // 6
[1, 2, 3].average(); // 2
[1, 2, 3].min(); // 1
[1, 2, 3].max(); // 3

Advanced aggregation for any Iterable:

var persons = [Person(age: 20), Person(age: 30), Person(age: 40)];
persons.sumBy((p) => p.age); // 90
persons.averageBy((p) => p.age); // 30
persons.count((p) => p.age < 35); // 2
persons.minBy((a,b) => a.age.compareTo(b.age)); // Person(age: 20)
persons.maxBy((a,b) => a.age.compareTo(b.age)); // Person(age: 40)

Safely access Iterable:

[].firstOrNull(); // return null instead
[].lastOrNull();  // of throwing error

[].firstOrElse(() => Placeholder()); // Produce default values
[].lastOrElse(() => Placeholder());  // on the fly

[1, 2, 3].elementAtOrNull(4); // Never go out of bounds
[1, 2, 3].elementAtOrElse(4, () => 0);

Group up data to match view:

var persons = [
    Person(name: "John", age: 21),
    Person(name: "Carl", age: 18),
    Person(name: "Peter", age: 56),
    Person(name: "Sarah", age: 61)
];

persons.groupBy(
    (p) => p.age < 40 ? "young" : "old",
    valueTransform: (p) => p.name
); // {"young": ["John", "Carl"], "old": ["Peter", "Sarah"]}

Chunking for easy pagination:

["a", "b", "c", "d", "e"].chunked(3); // [ ["a", "b", "c"], ["d", "e"] ]

More natural durations:

var duration = 5.minutes + 30.seconds;
duration += 0.5.hours;

Replace your classic for loop:

0.rangeTo(5); // [0, 1, 2, 3, 4, 5]
3.rangeTo(1); // [3, 2, 1]

var list = ["dog", "cat", "mouse"];
0.until(list.length); // [0, 1, 2]

list.forEachIndexed((index, value) {
    // index: 0, value: "dog"
    // index: 1, value: "cat"
    // index: 2, value: "mouse"
});

📑 API documentation

You can discover all 58 features in the API documentation. Each feature is well documented with an example.

Feel free to quickly jump into a topic:

📈 Improve

Supercharged will improve in future updates. Help me by reporting bugs, submit new ideas for features or anything else that you want to share.

  • Just write an issue on GitHub. ✏️
  • And don't forget to hit the like button for this package ✌️

supercharged's People

Contributors

felixblaschke avatar hawkbee1 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.