Giter Site home page Giter Site logo

flutter_ext's Introduction

Usage

Before:

Text("Title", style: Theme.of(context).textTheme.title);

After:

Text("Title", style: context.theme().textTheme.title);

Before:

Navigator.of(context).pop();

After:

context.navigator().pop();

Before:

final username = Provider.of<UsernameNotifier>(context, listen: false).value;

After:

final username = context.provider<UsernameNotifier>(listen: false).value;

Before:

expect(
  await Stream.fromIterable(["123", "abc"])
    .distinct((prev, next) => prev.length == next.length)
    .last,
  "123"
);

After:

expect(
  await Stream.fromIterable(["123", "abc"])
    .distinctBy((it) => it.length)
    .last,
   "123"
);

asStream()

final Stream<String> stream =  ["hello", "world"].asStream();
final Stream<String> stream = (() => "hello").asStream(); // defer
final Stream<String> stream = (() async => "hello").asStream();
final Stream<String> stream = Future.value("hello").asStream();
final Stream<String> stream = (() => Future.value("hello")).asStream(); // defer
final Stream<String> stream = [Future.value("hello"), Future.value("world")].asStream();
  test('should DateTimeRange.format()', () {
    expect(
      DateTime(1984, 11, 19).rangeTo(DateTime(1984, 11, 28)).format(),
      "November 19 - 28",
    );
    expect(
      DateTime(1984, 11, 19).rangeTo(DateTime(1984, 12, 2)).format(),
      "Nov 19 - Dec 2",
    );
    expect(
      DateTime(1984, 11, 19).rangeTo(DateTime(2020, 1, 2)).format(),
      "Nov 19, 1984 - Jan 2, 2020",
    );

    expect(
      DateTime(1984, 11, 19, 11, 59, 59).rangeTo(DateTime(1984, 11, 19, 12, 59, 59)).format(),
      //"Mon, 11/19 11:59 AM - 12:59 PM",
      "Mon 11:59 AM - 12:59 PM",
    );
  });

  test('should DateTime.formats()', () {
    expect(
      DateTime(1984, 11, 19).formats(end: DateTime(1984, 11, 23), from: DateTime(1984)),
      "November 19 - 23",
    );
    expect(
      DateTime(1984, 11, 19).formats(end: DateTime(1984, 11, 23), from: DateTime(2020)),
      "November 19 - 23, 1984",
    );
    expect(
      DateTime(1984, 11, 19).formats(end: DateTime(1985, 11, 23), from: DateTime(2020)),
      "1984 - 1985",
    );

    expect(
      DateTime(1984, 11, 1).formats(end: DateTime(1984, 12, 0), from: DateTime(2020)),
      "November 1984",
    );
    expect(
      DateTime(1984, 1, 1).formats(end: DateTime(1984, 12, 28), from: DateTime(2020)),
      "1984",
    );

    expect(
      DateTime(1984, 1, 1).formats(end: DateTime(1984, 12, 1), from: DateTime(2020)),
      "1984",
    );
    expect(
      DateTime(1984, 11, 1).formats(end: DateTime(1984, 12, 25), from: DateTime(2020)),
      //"Nov 1 - Dec 25, 1984",
      "1984",
    );
  });

test

Before:

expect(1, isNotNull);
expect([], isEmpty);
expect([1, 2, 3], [1, 2, 3]);
expect(1, isIn([1, 2, 3]));
expect(0, predicate((x) => ((x % 2) == 0), "is even"))

final list0 = [];
expect(list0, same(list0));

After:

isNotNull.of(1);
isNull.of(null);
isEmpty.of([]);
equals([]).of([]);
[1, 2, 3].isHaving(1); // isIn([1, 2, 3]).of(1)
predicate((x) => ((x % 2) == 0), "is even").of(0);

final list0 = [];
same(list0).of(list0);

Installation

  flutter_ext:
    git:
      url: https://github.com/yongjhih/flutter_ext.git
      path: flutter_dtx
  providerx:
    git:
      url: https://github.com/yongjhih/flutter_ext.git
      path: provider_dtx
  streamx:
    git:
      url: https://github.com/yongjhih/flutter_ext.git
      path: streamx
  test_ext:
    git:
      url: https://github.com/yongjhih/flutter_ext.git
      path: test_ext
  validatorx:
    git:
      url: https://github.com/yongjhih/flutter_ext.git
      path: validatorx

See Also

flutter_ext's People

Contributors

artemz avatar yongjhih 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.