Giter Club home page Giter Club logo

flutter-bloc-from_zero_to_hero's Introduction

Flutter Application using BLoC

A BLoC pattern is design pattern created by Google to seperate the UI from Business logic.

BLoC {Business Locgic Component}

Why BLoC?

  • BLoC as Design Pattern and StateManagement
  • Knowing the STATE of app is CRUCIAL
  • Presentation Layer & Logic behind it

Advantages of using BLoC?

  • Understand easily what's happening inside the app
  • More structured code, easier to maintain and test
  • Know & understand every state of the app
  • Work on a single, stable, popular and effective BLoC codebase

The main Differnt between BLoC Widgets


How can we provide the existing cubit/instance to another SCREEN?

Providing an instance of bloc/cubit to A SINGLE SCREEN is called LOCAL ACCESS

Providing an instance of bloc/cubit to MULTIPLE SCREENs is called ROUTE ACCESS

Navigation with ROUTES: requires

  • ROUTE Name
  • The associated PAGE/SCREEN
Flutter Routing Options
Anonymous Routing Named Routing Generated Routing
Routing without Name Navigation With a Route Name Navigation With a Route Name
Only the SCREENS are used to navigate ROUTES NAMES and their associated SCREENS are set up inside routes parameter of MaterialApp widget ROUTES NAMES and their associated SCREENS are set up inside a seperate onGenerateRoute function
Suitable for SMALL applications Suitable for SMALL-MEDIUM applications Suitable for LARGE applications

NOTES

  • You can NAVIGATE inside Flutter by using

    • Anonymous Routing (recmmended for SMALL projects)
    • Named Routing (recmmended for MEDIUM projects)
    • Generated Routing (recmmended for LARGE projects)
  • The key is to provide a UNIQUE INSTANCE of a bloc/cubit.

  • You SHOULDONT create MULTIPLE INSTANCES of the same bloc/cubit.

  • BlocProvider() CREATES & PROVIDES a NEW INSTANCE of a bloc/cubit.

  • BlocProvider.value() takes an ALREADY CREATED INSTANCE and then PROVIDES it further.

  • You can PROVIDE your cubit/bloc INSTANCES

    • LOCALLY-when you want to provide the instance to A SINGLE SCREEN
    • SPECIFICALLY-when you want to SPECIFICALLY PROVIDE the instance across one or more SCREENS
    • GLOBALLY-when you want to provide the instance ACROSS ALL OF YOUR SCREENS

flutter-bloc-from_zero_to_hero's People

Watchers

Ahmed Khallaf 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.