What Will I Learn?
- You will learn how to use JSON Serialization inside of Dart
- You will learn how to build a set of objects and annotate them for code generation
- You will learn how to use build runner to generate code with JSON annotation and JSON serializable
- You will learn how to avoid mirrors and reflection in a Dart/Flutter application.
Requirements
- IDEA intellij or Visual Studio Code with the Dart/Flutter Plugins
- The Dart SDK and the Flutter SDK
- A fair understanding of Mobile development and Imperative or Object Oriented Programming
Difficulty
- Intermediate
Description
In this Flutter Video tutorial, we create a series of objects to help with JSON serialization and decoding for our weather application. We make use of the JSON Annotation, JSON Serializable and Build Runner plugins to annotate these objects and then generate a large amount of boilerplate code that will help us convert our responses and requests to and from JSON. This not only helps us save time by creating boilerplate code, it also helps with performance.
In the past flutter tutorials, we have mostly been working with fairly simple JSON objects. As a result of this, it has been fairly easy for us to create methods and objects which let us take those JSON data objects into our dart code as dart objects. Now that we are using the OpenWeatherMap API which features many nested objects, we need a better method to decode our JSON objects. In Dart, typically when you want to decode and encode a piece of data into JSON you make use of mirrors and reflection. The dynamic nature of these abstractions can strain the performance of our applications especially when dealing with larger JSON objects.
The solution for this problem is Serialization and Code Generation. By using Serialization, we can avoid having to use Mirrors and Reflection in our Flutter application. Also, with the Code Generation, we can now generate multiple pieces of code that we would have had to manually implemented otherwise. In this way, we can easily expose various JSON Data objects to our application and also create an inner state for the application.
The source code for this project can be found here
Open Weather API can be found here
Video Tutorial
Projects and Series
Stand Alone Projects:
- Dart Flutter Cross Platform Chat Application Tutorial
- Building a Temperature Conversion Application using Dart's Flutter Framework
- Managing State with Flutter Flux and Building a Crypto Tracker Application with Dart's Flutter Framework
Building a Calculator
- Building a Calculator Layout using Dart's Flutter Framework
- Finishing our Calculator Application with Dart's Flutter Framework
Movie Searcher Application
- Building a Movie Searcher with RxDart and SQLite in Dart's Flutter Framework (Part 1)
- Building a Movie Searcher with RxDart and SQLite in Dart's Flutter Framework (Part 2)
- Building a Movie Searcher with RxDart and SQLite in Dart's Flutter Framework (Part 3, Final)
Minesweeper Game
Curriculum
- Building a Multi-Page Application with Dart's Flutter Mobile Framework
- Making Http requests and Using Json in Dart's Flutter Framework
- Building Dynamic Lists with Streams in Dart's Flutter Framework
- Using GridView, Tabs, and Steppers in Dart's Flutter Framework
- Using Global Keys to get State and Validate Input in Dart's Flutter Framework
- The Basics of Animation with Dart's Flutter Framework
- Advanced Physics Based Animations in Dart's Flutter Framework
- Building a Drag and Drop Application with Dart's Flutter Framework
- Building a Hero Animation and an Application Drawer in Dart's Flutter Framework
- Using Inherited Widgets and Gesture Detectors in Dart's Flutter Framework
- Using Gradients, Fractional Offsets, Page Views and Other Widgets in Dart's Flutter Framework
- Making use of Shared Preferences, Flex Widgets and Dismissibles with Dart's Flutter framework
- Using the Different Style Widgets and Properties in Dart's Flutter Framework
- Composing Animations and Chaining Animations in Dart's Flutter Framework
- Building a Countdown Timer with a Custom Painter and Animations in Dart's Flutter Framework
- Reading and Writing Data and Files with Path Provider using Dart's Flutter Framework
- Exploring Webviews and the Url Launcher Plugin in Dart's Flutter Framework
- Adding a Real-time Database to a Flutter application with Firebase
- Building a List in Redux with Dart's Flutter Framework
- Managing State with the Scoped Model Pattern in Dart's Flutter Framework
- Authenticating Guest Users for Firebase using Dart's Flutter Framework
- How to Monetize Your Flutter Applications Using Admob
- Using Geolocator to Communicate with the GPS and Build a Map in Dart's Flutter Framework
- Managing the App Life Cycle and the Screen Orientation in Dart's Flutter Framework
- Making use of General Utility Libraries for Dart's Flutter Framework
- Interfacing with Websockets and Streams in Dart's Flutter Framework
Posted on Utopian.io - Rewarding Open Source Contributors