Code Monkey home page Code Monkey logo

builders's Introduction

builders

Use Consumer, Select and BlocConsumer in any System Injector

How Install

Open your project's pubspec.yaml and add flutter_modular as a dependency:

dependencies:
  builders: any

You can also provide the git repository as source instead, to try out the newest features and fixes:

dependencies:
  builders:
    git:
      url: https://github.com/Flutterando/builders

Configure your System Injector

You can use any System Injector for example Modular or Get_it.

main(){
    
    //using Modular
    Builders.systemInjector(Modular.get);
    
    //using Get_it
    Builders.systemInjector(GetIt.I.get);

    runApp(YourAmazingApp());
}

Using in your Flutter App

Here are some Builders known to the community. Here we have Consumer and Selector (Originally from the Provider package) and BlocConsumer, (from the flutter_bloc package)

Consumer

Consumer is used when you want to listen to a class that extends from ChangeNotifier:

class MyCounter extends ChangeNotifier {

    int value;

    increment() {
        value++;
        notifyListeners();
    }

}

in your View:

Consumer<MyCounter>(
    builder: (context, myCounter){
        return Text('${myCounter.value}');
    }
);

Selector

Selector works like Consumers, however you can select and listen to only one property of your Object.

Selector<MyCounter, int>(
    selector: (myCounter) => myCounter.value,
    builder: (context, value){
        return Text('$value');
    }
);

BlocConsumer

Listen to custom streams from the bloc package (Bloc and Cubit).

class MyCounterBloc extends Cubit<int> {

    MyCounterBloc(): super(0);

    increment() => emit(state + 1);

}

in your View:

BlocConsumer<MyCounterBloc, int>(
    builder: (context, state){
        return Text('$state');
    }
);

Features and bugs

Please send feature requests and bugs at the issue tracker.

This README was created based on templates made available by Stagehand under a BSD-style license.

builders's People

Contributors

ancientz avatar jacobaraujo7 avatar bwolfs2 avatar

Watchers

James Cloos 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.