Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anyone using bloc in production? #139

Open
sawankumarbundelkhandi opened this issue Mar 11, 2019 · 128 comments
Open

Anyone using bloc in production? #139

sawankumarbundelkhandi opened this issue Mar 11, 2019 · 128 comments
Labels
discussion Open discussion for a specific topic

Comments

@sawankumarbundelkhandi
Copy link

sawankumarbundelkhandi commented Mar 11, 2019

Similar to:
reactiveui/ReactiveUI#979
PrismLibrary/Prism#1016
orientechnologies/orientdb#4806
brianegan/flutter_redux#86

Use the following template:

If available on stores
iOS:
Android:

If open source
Source Code:

Your opinion
Version: ?
Years of experience: ?
Good: ?
Bad: ?

Thank you very much!

@felangel felangel added the discussion Open discussion for a specific topic label Mar 11, 2019
@jorgecoca
Copy link
Collaborator

We do! But of course, we/Felix also wrote the package... we are very happy with the results so far, and as you can see in the examples/docs/articles, we are investing more and more to make this package as good, easy, performant and high quality as possible ;)

@nhwilly
Copy link

nhwilly commented Apr 13, 2019

The impressive part of this package is the documentation and fully filled out examples. The number of "counter" apps that really don't tell you about localization, authentication and other real problems has just swamped the search process.

I intend to build a complex app with this (after trying 3 others) and feel good about the chances of success after see the docs and samples.

Thanks so much for sharing this.

@jorgecoca
Copy link
Collaborator

jorgecoca commented Apr 13, 2019

@nhwilly let us know about your experience! we hope you find this package very easy to use 🤞 but if you have any issues/questions, we will gladly help you!

@warriorCoder
Copy link
Contributor

@nhwilly Can you define "complex app" for me?

I've also been considering adding complexity to the sample apps. Mainly I'm thinking of extending the todo app to include a layer above the todo's called projects, adding side navigation and a firebase login with Google, Facebook, Phone Number, and Email.

Personally, I feel like that would constitute a complex app.. would you agree or are there other things you think it should have?

@nhwilly
Copy link

nhwilly commented Apr 17, 2019

I'll just point out some things that I think I'll have to work out:

  • Centralized web api calls that can handle an authentication failure (401), prompt the user for a password if the refresh token fails and then automatically try the operation again.
  • A side drawer menu that deals with permissions for presenting some menu items.
  • A reusable crud block to handle the basics stuff from so many items
  • A barcode scanner (this can be done with ML, I think, if they've opened up the camera stream.)

Those are just some of the things that come to mind on the fly here.

@nhwilly
Copy link

nhwilly commented Apr 20, 2019

Saw some recent changes. They look great.

@ftognetto
Copy link

I’m just about to start a porting of an app from ionic to flutter and after digging around about state management in flutter i choosed to use flutter_bloc because is the only one which gave me some practical examples about authentication or managing long lists. Thank you!

@craiglabenz
Copy link

I'm grinding every day on a soon-to-be production app using flutter_bloc. Unbelievably happy so far!

@ammaratef45
Copy link

I wonder how much I time I would spend to refactor exacting repo into using bloc.
Any Ideas? I'm mainly talking about https://github.com/ammaratef45/Attendance if you may take a look.

@felangel
Copy link
Owner

felangel commented May 5, 2019

@ammaratef45 I think you can do it in less than a week. If you decide to give it a shot, I’m happy to help 👍

@ammaratef45
Copy link

@felangel I will be glad to have your help
I will use this issue to track the work ammaratef45/Attendance#88
Can you leave some instruction and hints? PRs are very welcome too.

@ammaratef45
Copy link

I've started refactoring with the help of @felangel
I hope is facilitates unit testing and maintainability, I will write a blog post about my experience with it and share it with you guys next week 👍

@bobwiller
Copy link

Love the recent updates - especially w/the Listener and Tree classes. One area I am still struggling with from a design perspective is how "big" or "small" a bloc should be. I am getting to the point where every piece of UI that has its own state has its own bloc, which seems like a lot of overhead - would love to hear from everyone else if they have any lessons learned or best practices around bloc "size" and scope?

@felangel
Copy link
Owner

felangel commented May 9, 2019

@bobwiller thanks for the positive feedback! We really appreciate it 😄

Regarding your question, I would love to hear more about the overhead you are referring to and some sample use-cases you have in your own applications.

In general, I think it's a tough question to answer but I would say a good rule of thumb is if your bloc's state has properties that are unrelated, then it's probably managing state that is too broad and can be split into multiple, smaller blocs. I would try to keep blocs as small and as focused as reasonably possible (a bloc should only manage state for a single feature) but you should definitely not feel like there's a lot of overhead associated with managing these blocs; that might be a sign that your blocs are too small.

It'd be awesome if you can share some concrete use-cases and we can try to give some suggestions about how to break them up into one or more blocs 👍

@erwintan96
Copy link

hi @felangel, may I ask your opinion about this article https://medium.com/flutterpub/effective-bloc-pattern-45c36d76d5fe?

especially this part :

You can clearly see that multiple BLoC providers are nested. Now you must be worried that if you keep adding more BLoCs in that same chain then it will be a nightmare and you will conclude that BLoC pattern cannot scale. But let me tell you that there can be a special case(a BLoC only holding the UI configurations which is required across the app) when you need to access multiple BLoCs anywhere down the Widget tree so for such cases the above nesting is completely fine. But I would recommend you to avoid such nesting most of the time and provide the BLoC from where it is actually needed.

because i read a lot of articles about BLoC Pattern and I was confused.
Maybe your opinion can make me not confused anymore
btw, this package is cool and has great examples! Thank you so much 🍻 🍻

@felangel
Copy link
Owner

Hey @erwintan96 👋
I think overall the article is pretty good. For the specific section you mentioned, I would add that you should always keep state/blocs scoped to the part of the widget tree that needs it. Avoid making all blocs global unless they need to be. In addition, if you’re using the bloc library, you can use BlocProviderTree to avoid nesting when providing multiple blocs.

Thanks for the positive feedback and hope that helps! 👍

@erwintan96
Copy link

erwintan96 commented May 13, 2019

hi @felangel 🍻 , i want to ask again..
why did you use stateless widget rather than statefull widget on your example https://medium.com/flutter-community/flutter-todos-tutorial-with-flutter-bloc-d9dd833f9df3 at detail screen, and etc..
you used bloc on detail screen but you didn't dispose it.. Is it okay?
stateless widget doesn't have dispose method.. 😅 😅

@felangel
Copy link
Owner

Hi @erwintan96 the Detail Screen didn't create the bloc, it just accessed it using the BlocProvider so it does not need to be stateful and does not need to dispose the bloc. The bloc was created and disposed in the Home Screen. Hope that helps 👍

@ftognetto
Copy link

Hi @felangel i’m starting the porting of a social network app from ionic to flutter.

What do you think about bloc for global state management?

For example i will have to implement a bloc for authenticated user, one for the posts, one for notification, one for logged user followers/followings and so on, and many of them should stay at the top of the app widget tree to let app to be synced.
Is this good for performance?

When I press like in a screen and then navigate to another screen where there is the same post I have to find that post already liked or when I follow someone and then I navigate to my profile I have to find the same followed user.

I normally used redux for this kind of central state management but now I would like to manage everything with bloc and not only use it for local state and then falling back to redux for global state.

Thank you 🙏 ☺️

@felangel
Copy link
Owner

@quantosapplications that should be fine if you need them to be globally available. Only the portions of your app wrapped in BlocBuilder will be rebuilt when the respective bloc's state changes 👍

@ftognetto
Copy link

Thank you @felangel, so you do think that there are no worries about putting 5/10 different bloc on top of material app?
And also do you think that this is a good design pattern?

I’m stucked on where to put blocs, if is more correct a bloc-per-page way or design one bloc every big functionality of the app.

@felangel
Copy link
Owner

felangel commented May 16, 2019

@quantosapplications I think it's fine as long is it makes sense. Things like AuthenticationState make sense to be global because they have an impact on the entire application. I would argue that other things like followers/following should probably not be global because they aren't needed globally. If you're logged out of the application that state probably doesn't make sense. I would always define and provide the bloc at the closest common ancestor of all the widgets that rely on that state. It might help to draw your widget tree and circle all widgets that rely on the state. Then, you can find their closest common ancestor and provide the bloc there. Hope that helps 👍

@narcodico
Copy link
Contributor

I’m just about to start a porting of an app from ionic to flutter and after digging around about state management in flutter i choosed to use flutter_bloc because is the only one which gave me some practical examples about authentication or managing long lists. Thank you!

You might wanna update your avatar as well :)

@felangel felangel pinned this issue May 27, 2019
@felangel felangel changed the title Anyone using bloc in production apps? Anyone using bloc in production? May 27, 2019
@LukeBrumfield
Copy link

I am working with Bloc to recreate an app done in react native to an app that have mobile and web versions. I am using flutter and angulardart, hopefully using just flutter and its web version when the development preview goes prime time. It is a very simple app in terms of what it does on the front end (login and submit small bits of data with a more complicated backend). Maybe 4 screens when finished and all the state management shown in the firebase login example.

@azimuthdeveloper
Copy link

I'm about to start transitioning from my Xamarin Forms application to flutter, using this package. I'm super keen for any refactoring help that anyone could offer.

It's a huge change for me (learning dart etc) but I just can't use XF any more. So many breaking changes in the latest release ;_;. Plus that hot reload!

@Allan-Nava
Copy link

I solved , thx!

@Roomka
Copy link

Roomka commented May 31, 2020

Hi everyone!

I am working on a flutter timer app following the nice tutorial https://medium.com/flutter-community/flutter-timer-with-flutter-bloc-a464e8332ceb using flutter_bloc package.

Does anyone have a suggestion on how to refactor this example https://github.com/felangel/bloc/tree/master/examples/flutter_timer in order to have the timer work also in background ?
I saw that some guides suggest Timer class but it seems like the callback method is not very testable as it usually has references to widget variables and uses setState.

Thanks and congrats for the nice package,
Roman

@enricobenedos
Copy link

Hi everyone!
After a lot dev builds my app is finally published on production.
flutter_bloc package is something essential for me!
Thank you @felangel and thank to all the contributors of this beautiful package!

(Sometimes after hours of development it happens that I have problems with the library.. It is always my fault 😆)

@YeungKC
Copy link

YeungKC commented Jun 28, 2020

Hi everyone!
I want to know the project awals about app?
I use bloc make a package about listens to children inside scrollview, may it help some people?

Source Code: https://github.com/YeungKC/widgets_visibility_provider
Good: Using bloc can help me pass the state conveniently, and its granularity is flexible, which is very easy to use~

@hawkinsjb1
Copy link

Hey guys!
I've been using this library as a state management solution for an on-going enterprise level app, as well as a recently-published time tracker that integrates with Basecamp 3
https://www.trackteamtime.com

It took some practice to learn how to use the package entirely as intended because there are lots of ways to misuse the tools, but the payoff has been great and I'm so glad I don't have to implement custom blocs myself!

@muhammadmateen027
Copy link

Hi Guys,

I'm using BLoc library from quite long time and published 1st version of an enterprise level application on October 17, 2019. Till now I've published 22 version for this application and keep going on. App is available on both Android and IOS platform and you can access easily.

It's quite nice library and now I'm facing some hard time while upgrading version. Requires a little help from BLOC team especially from @felangel . Please It's a humble request to update your Weather Application example with latest version of BLoc. It's really helping me a lot.

Thanks and regards,
Mateen

@felangel
Copy link
Owner

@muhammadmateen027 that's amazing! I will prioritize updating the weather tutorial but in the meantime you can always refer to the weather example source code since the code itself is up-to-date.

@theweiweiway
Copy link

Been using it at our start-up Honeybee Hub since last November when we first pushed out our app - It's be awesome and has made state management a breeze!

If anyone is interested, the app is here on iOS and android

Thanks Felix for the package - also thanks for all of the immediate and detailed support whenever we had questions!

@firatcetiner
Copy link

firatcetiner commented Dec 21, 2020

Oh boy here we go again!

I have published my own first application on Google Play Store last month. I hope it will be on AppStore in next month too.

Android: Link

I used classic Bloc to manage app's authentication state. Thanks to Cubit and a little bit of object-oriented programming I managed to create highly modular codebase for this application that I'm really happy with. In fact, although this app has more than 25 views that show users a list of items, I only use a single CubitState class to represent all of them again with the help of object-oriented programming and equatable package. I even tried to implement my own undo/redo logic but surrendered to replay_bloc at last :)

Good: My opinion is that bloc and flutter_bloc with all of its extensions are pretty awesome since all of the variants of Bloc supports Stream operations by default. Before migrating nearly all of my business logic to Bloc or Cubit I tried many other state management solutions including Provider, Redux and MobX. After weeks of examination I decided to continue with Bloc because the idea of being able to utilize my state as Stream is very useful, and as I said before it reminds me of a state machine and I love automata theory :)

Bad: Not a bad thing but a feature request: I think flutter_bloc should have a special widget like Selector as we have in Provider, not sure how it's affect the other parts of the architecture.

A really personal note: Some people are crying about bloc/flutter_bloc to produce boilerplate code than other state management solutions but I don't think so. If you know what you are doing you can write less code and still have good performance and plus modularity with flutter_bloc.

@felangel Thanks again!

Version: latest

Years of experience: 1.5 (Flutter)

I'm really not comfortable for sharing the link of the application since it may contain google ads in the future releases. @felangel Let me know and I can remove the link and maybe add some screenshots from the application :D

@Add00w
Copy link

Add00w commented Dec 23, 2020

Oh boy here we go again!

I have published my own first application on Google Play Store last month. I hope it will be on AppStore in next month too.

Android: Link

I used classic Bloc to manage app's authentication state. Thanks to Cubit and a little bit of object-oriented programming I managed to create highly modular codebase for this application that I'm really happy with. In fact, although this app has more than 25 views that show users a list of items, I only use a single CubitState class to represent all of them again with the help of object-oriented programming and equatable package. I even tried to implement my own undo/redo logic but surrendered to replay_bloc at last :)

Good: My opinion is that bloc and flutter_bloc with all of its extensions are pretty awesome since all of the variants of Bloc supports Stream operations by default. Before migrating nearly all of my business logic to Bloc or Cubit I tried many other state management solutions including Provider, Redux and MobX. After weeks of examination I decided to continue with Bloc because the idea of being able to utilize my state as Stream is very useful, and as I said before it reminds me of a state machine and I love automata theory :)

Bad: Not a bad thing but a feature request: I think flutter_bloc should have a special widget like Consumer as we have in Provider, not sure how it's affect the other parts of the architecture.

A really personal note: Some people are crying about bloc/flutter_bloc to produce boilerplate code than other state management solutions but I don't think so. If you know what you are doing you can write less code and still have good performance and plus modularity with flutter_bloc.

@felangel Thanks again!

Version: latest

Years of experience: 1.5 (Flutter)

I'm really not comfortable for sharing the link of the application since it may contain google ads in the future releases. @felangel Let me know and I can remove the link and maybe add some screenshots from the application :D

Bloc has BlocConsumer which combines BlocListener and BlocBuilder

@jdouitsis
Copy link

Does anyone have any experience working with BloC to BloC communication? I have a bluetooth BloC that takes input from sensors and I want it to automatically send the data vai my Sockets BloC to the server for data storage

@firatcetiner
Copy link

firatcetiner commented Feb 9, 2021

Does anyone have any experience working with BloC to BloC communication? I have a bluetooth BloC that takes input from sensors and I want it to automatically send the data vai my Sockets BloC to the server for data storage

Have you tried injecting one of the BLoC instances to another? You can listen bluetooth BLoC with .stream.listen((event){}) after injecting it.

Here is an abstraction:

import 'dart:async';

import 'package:flutter_bloc/flutter_bloc.dart';

class BluetoothBloc extends Bloc<BluetoothEvent, BluetoothState> {}

class SocketBloc extends Bloc<SocketEvent, SocketState> {
  final StreamSubscription<BluetoothState> _stateSubscription;
  SocketBloc(BluetoothBloc bluetoothBloc) {
    _stateSubscription = bluetoothBloc.stream.listen(_onListenBluetoothState);
  }

  void _onListenBluetoothState(BluetoothState state) {
    // do something with the latest state
  }

  @override
  Future<void> close() async {
    await _stateSubscription.cancel();
    return super.close();
  }
}

@jdouitsis
Copy link

Does anyone have any experience working with BloC to BloC communication? I have a bluetooth BloC that takes input from sensors and I want it to automatically send the data vai my Sockets BloC to the server for data storage

Have you tried injecting one of the BLoC instances to another? You can listen bluetooth BLoC with .listen((event){}) after injecting it.

Here is an abstraction:

import 'dart:async';

import 'package:flutter_bloc/flutter_bloc.dart';

class BluetoothBloc extends Bloc<BluetoothEvent, BluetoothState> {}

class SocketBloc extends Bloc<SocketEvent, SocketState> {
  final StreamSubscription<BluetoothState> _stateSubscription;
  SocketBloc(BluetoothBloc bluetoothBloc) {
    _stateSubscription = bluetoothBloc.listen(_onListenBluetoothState);
  }

  void _onListenBluetoothState(BluetoothState state) {
    // do something with the latest state
  }

  @override
  Future<void> close() async {
    await _stateSubscription.cancel();
    return super.close();
  }
}

Perfect! Thanks a bunch

@LautaroLobo12
Copy link

I work on a project at my company, the team has been using Bloc for some time now, I joined recently to the project and I'm very happy with it.

Android: https://play.google.com/store/apps/details?id=ues21.edu.ar
iOS: https://itunes.apple.com/us/app/universidad-siglo-21/id1203596645?ls=1&mt=8

btw long live Flutter!!

@arsamme
Copy link

arsamme commented Mar 20, 2021

Android: https://play.google.com/store/apps/details?id=app.forghoon.driver

I've 5 years experience in mobile development but two years in flutter.
Bloc is awesome IMO!

@felangel
Copy link
Owner

felangel commented May 29, 2021

The I/O Photo Booth for Google I/O 2021 was made with Bloc! 🎉 💙

GitHub Repo: https://github.com/flutter/photobooth
Web App: https://photobooth.flutter.dev/

@omerasif57
Copy link

omerasif57 commented Jun 3, 2021

I am bit new to flutter. learning and building ready-to-publish app to play store side-by-side. I am considering bloc for my dead simple app which store data in local db. (Experimenting with hive for now). Knowing a bit about state management, I am still confused among the ChangeNotifier-Provider and bloc pattern.
My use-case involves CRUD of a simple model with id, string, type and presenting the model in only two pages, Home and Detail.
As I see it provider is allowing me quick and easy implementation. bloc provide more sophisticated pattern but a bit of bloc designing overhead. I might be wrong here but anyways. Please advise how to approach this case with agility.

@dutch-game-studio
Copy link

We use Bloc in production. It is amazing!

@squallsama
Copy link

Use the following template:

If available on stores
iOS: https://apps.apple.com/us/app/wallpapers-lab/id1527915803
Android: https://play.google.com/store/apps/details?id=com.drlabx.wallpapers

Your opinion
Version: 7.2.0
Years of experience: 1
Good: It's very clear how to handle different event and apply appropriate states
Bad: Would be great to use it with isolates and move some complicated logic into background threads

@LeonidArefev
Copy link

Currently in 2 Flutter projects. One is internal company project. Another is OpenSource PrivacyBlur: https://github.com/MATHEMA-GmbH/privacyblur
And i suppose for the next projects also.

@yuanhoujun
Copy link

https://github.com/air-controller/air-controller-desktop
Mine here.

@Livinglist
Copy link

Livinglist commented Jun 3, 2022

iOS: App Store
Android: Google Play

Source Code: https://github.com/Livinglist/Hacki

Years of experience: 2
Good: everything, I’m a bloc fanboi
Bad: nothing

@aytunch
Copy link

aytunch commented Aug 10, 2022

Sponty: Spontaneous Gatherings
https://sponty.app
iOS: App Store
Android: Google Play

Years of experience: 4
Good: Perfect for complex state machine scenarios. Cubit to Cubit communications are essential in our app. We use Cubits extensively and Blocs rarely (only when debouncing is needed) We are bloc fans too :)
Bad: It would be much better not needing to use Freezed and somehow state immutability were to be integrated in to bloc package.

@tenhobi
Copy link
Collaborator

tenhobi commented Mar 20, 2023

We are using Bloc/Cubit in production for two of Czechia's biggest school information systems, including the newly redesigned Škola OnLine app.

iOS: App Store
Android: Google Play

Please take a look at our case study https://www.netglade.com/en/reference/skolaonline

Years of experience: 6 with Flutter, 4 with Bloc (both since the beginning)
Good: In love with how the app state can be fragmented into small pieces that can be very well testable. Also, Cubit vs. Bloc is a nice addition, so everybody can either reduce the boilerplate a bit by using functions or use some advanced functions like concurrency by using streams.
Bad: While we have no meta-programming and code generation is sometimes meh, the code is a bit more verbose than it could be. But I do not mind.

@charlieforward9
Copy link

charlieforward9 commented Aug 22, 2023

I just opened #3940 about performance feedback & enabling Github Discussion, & this issue looks like a relevant transfer to a Discussion. I have been having performance issues and as there are currently no official docs on it would appreciate discussing it more in a non-issue setting.

However, comments like this:

Only the portions of your app wrapped in BlocBuilder will be rebuilt when the respective bloc's state changes

&

I would always define and provide the bloc at the closest common ancestor of all the widgets that rely on that state. It might help to draw your widget tree and circle all widgets that rely on the state. Then, you can find their closest common ancestor and provide the bloc there.

helped me check and optimize some code, thank you

@nilekell
Copy link

Hey everyone, I found BLoC after trying to build my first app with Flutter and getting a headache using the native state management. 6 months later, I released my app with BLoC with more features. It particularly helped me separate feature logic.

My app is a personal, private, simple receipt manager with OCR Searching, PDF exporting, a folder system & more. Check it out here (for free).

https://apps.apple.com/us/app/receiptcamp/id6460006476

https://play.google.com/store/apps/details?id=com.nilekell.receiptcamp.app

@chenjie4255
Copy link

SimFlyPad, the Android version is using bloc.

https://play.google.com/store/apps/details?id=com.seeingsky.simfly_pad

@FarisArmoush
Copy link

I've built an open source mobile application using bloc called Groceries and I gotta say, I've never been happier, working with Bloc is such an amazing experience, its architecture is what separates it from other state management solutions. I'm a huge advocate for clean code and clean architecture, and bloc integrates seamlessly with the software i build. All production applications I've worked on didnt use bloc, and I've noticed more bugs occuring with those projects more than Groceries. What also separates Bloc from all other state management solutions is how its built, it tells you how much of a great engineer @felangel is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Open discussion for a specific topic
Projects
None yet
Development

No branches or pull requests