Comprehensive Guide for Flutter Bloc Library v1.0.0

A Comprehensive Guide for Flutter Bloc Library v1.0.0

Author image By Manish Patel  |  Wednesday, November 20, 2019 03:27 PM  |  3 min read  |   769

A Comprehensive Guide for Flutter Bloc Library v1.0.0

Flutter is a Google-powered app development kit that allows app developers to develop cross-platform applications such as Android, iOS, Web, Windows, and Mac. Day by day, Flutter is gaining popularity, and so are its developers. To make things easy for devs, Google introduced the Bloc pattern flutter back in 2018 during its Google I/O event. Since then, it’s been almost a year since introducing bloc, and finally, Bloc Library is updated now! So, before we dig in more for the latest updates, firstly, we need to know more about bloc and how it works with Flutter considering newbies.

What is Bloc?

Bloc stands for Business Logic Component(Bloc), which is a core library developed to reduce the workload on Flutter app developers using the idea of code testability and reusability. To understand and get a better idea of the bloc, you can think of it as a brain. This bloc library simplifies the reactive app development process by allowing Flutter app developers to convert the events into states. And to get bloc output in a state, events, or you can say user input that comes from one side; bloc mirrors the same code in response to generate output. Using the same principle, Flutter UI widgets listen to states and display responses on the screen as a reaction to user action. And, this is how bloc works. However, when you write your Flutter app code from scratch, you need to write much boilerplate code too.

But using Bloc have its advantages, such as…

  • To know the current app state
  • Simplifies app case testing process
  • Record user interaction to make data-driven conclusions
  • Reuse components within the app as well as in other apps
  • Use a single code base with the same pattern
  • Faster the app development process

Apart from the bloc’s core library, there are two other libraries named flutter_bloc and angular_bloc that work simultaneously with the bloc for a faster app development process. The tremendous growth in the Flutter community has played a significant role in the result of improvising the existing bloc library. However, this library assists you in dealing with the complexities of existing blocs, streams, and sinks. To have the best code practice, you can use their extension for both VS Code and IntelliJ which provide code snippets and an instant bloc class creation facility. Now you know about blocs, and their working pattern, so let’s move further and see what’s new in the latest Library 1.0.0 update.

What’s new in the latest Bloc Library 1.0.0

What’s new in the latest Bloc Library 1.0.0

1. Bloc as a Stream

In the latest update to bloc library v1.0.0, all blocs are now converted into streams, which means you no longer need to use Stream< state> to get to state. Instead, the Flutter app developer can quickly know the existing state stream directly from the bloc itself. It also helps us to remove the need for using currentState property and reuse the bloc state property to fetch the value of the state. The main reason is to reduce confusion and differentiate both blocs. state and bloc.currentState. Working with the bloc’s state stream should now feel very intuitive, especially to those coming from StreamControllers and Subjects.

2. Bloc as a Sink

With the update to the bloc library, all blocs are converted into Sinks. This makes it even easier for Flutter Developer to continue using the traditional add sink API instead of dispatch to notify the Bloc for a new event. Also, the dispose of objected in support of close. From now while using the art analyzer, it shows warnings if you forget to call blocs using close. Yet, it is performed naturally by the BlocProvider.

3. Testing Improvements

This time there is one more new package, which is bloc_test which is included in the latest library update. The main aim of the bloc_test package is to simplify stub a bloc’s state stream through when listening. However, this is still in beta. Still, it is expected to be helpful for developers to test helpers that are specially designed for the bloc library. After this, it is assumed to get more such extra testing helpers that will come preloaded in the upcoming updates.

4. Official Documentation

To make it easier for developers to find bloc library and tutorials under one hood, old pub.dev stuff is now moved into the new domain block library. dev. This time it comes with official documentation so that newbies can learn it quickly. And we recommended you go through it cause it helps you to plan bloc usage in your next app development process.

So, these were four significant changes that happened in the update to the latest Bloc library. But if you want to see it in action before you use it in your next app development project, you can consider the Counter app. Which is a pure Dart app made up using CounterBloc? Let us know what you think about this newly introduced Bloc Library v1.0.0 by commenting below.

 

A Comprehensive Guide for Flutter Bloc Library v1.0.0

Contact Us

 

 


Author image

Manish Patel

Manish Patel is a Co-Founder of Concetto Labs, a leading mobile app development company specialized in android and iOS app development. We provide a one-stop solution for all IT related services.

Why Our Client Love Us?

  • Fast kick-off
  • Agile Ready
  • 98% Client Retention
  • 360-Degree solutions

Our integrity and process focuses largely on providing every customer the best recommendations for their respective business. Our clients become recurring customers because we always go beyond their expectations to deliver the best solutions.

Get In Touch
Kamika Kilgore
Customer for over 2 years Kamika Kilgore United States

Concetto Labs has been a fantastic partner in consistently delivering high quality, high value solutions to our organization. Their team does an excellent job of first understanding our processes and requirements, and then translating them into solutions that meet or exceed expectations. Concetto Labs has helped us simplify multiple processes and workflows as well as suggested additional improvements we had not considered. Their communication and follow-through are top tier. They have proven themselves to be a trusted partner and we look forward to leveraging their services on future projects.

Mr. Sieva Savko
Customer for over 4 years Mr. Sieva Savko Norway

Concetto Labs have provided us with a tremendous amount of help. Their competence in various IT fields led to a positive outcome while facing different challenges. A lot of value was given by their helpful professional staff. To describe this company in three words: effectiveness, collaboration, trust. I would also like to personally thank Mr. Tejas Patel for his positive, friendly, and highly competent approach. The all-around support provided by him made every task at hand a no-brainer.

Miss. Caroline Jack
Customer for over 4 years Miss. Caroline Jack South Africa

It has been an absolute pleasure working with the Concetto Labs team! We have worked together on a few projects now, all of which have been successful. You can rely on good communication and response times from these guys. And they go above and beyond to ensure that the result is achieved. Because of their great service, they have become an integral part of our business and we will continue to use them going forward.

Mr. Richard Bartlett
Customer for over 3 years Mr. Richard Bartlett United States

Concetto Labs is a group of incredibly talented individuals. They are very responsive and communicate with you each and every step of the process. I worked with Manish Patel throughout the entire process and must say that I have never conducted business with a more honest and professional individual. Together with his team, Manish created www.travcentiverewards.com exactly how we envisioned it to be. Thanks for all of your hard work.

Mr. Conrad Abraham
Customer for over 2 years Mr. Conrad Abraham United States

Concetto Labs team is my go-to for any simple or complex development projects. They have risen to the challenge. Great project management, communication, and super quick turnaround. I've done multiple projects with them and don't plan on changing that.

Mr. Edward Chin
Customer for over 4 years Mr. Edward Chin Canada

Concetto Labs was able to bring my complex idea to life. Throughout the project, Concetto Labs maintained constant communications and was always professional - considering I had no experience in what I wanted to create their welcoming attitude, patience, and knowledge in the field created the perfect environment to work in. I was so impressed with their work that I've kept them on board as my go-to experts. Thanks for the worthwhile experience and the breathtaking product.

Karuna Govind
Karuna Govind CTO & Co Founder (Coupay) London, UK

We started working with Concetto Labs due to the influx of work on mobile (Flutter) and frontend (React.js). It's been fantastic working with them. Good, consistent communication and good quality of work means they may be our first choice for many projects to come.

Arunabha Choudhury
Arunabha Choudhury Director (Fuzzann Technologies Private Limited) India

We are a healthcare IT company and wanted to build a Mobile Application for both Android and IOS using Flutter. The Concetto Lab team has been very patient with our project requirements and made sure all our queries are answered. It was a great show of professionalism and customer relationship. Even during the project, the team was very accommodating of all the changes we requested. The project was delivered successfully and we deployed the app in the Android Play Store. Overall, the entire process has been very transparent and the team was able to deliver exactly what we had envisioned the project outcome to look like.

GlobalClients
Good Firms Clutch App Futura Microsoft Associate Mobile App Top Developers Gesia