Fixing an App with a Deprecated Library and API - Weather App Part 5
Repository
https://github.com/flutter/flutter
What Will I Learn?
- How to update libraries for Flutter
- How to find and implement a new library
- How to deal with Deprecated Libraries
- How to deal with Deprecated APIs
- How to update RxCommand and RxWidgets
- How to resolve Dependency issues
- How to update to Dart 2.0 and Flutter 1.0 from Dart 1.x
Requirements
System Requirements:
- IDEA intellij, Visual Studio Code with the Dart/Flutter Plugins, Android Studio or Xcode
- The Flutter SDK on the latest Master Build
- An Android or iOS Emulator or device for testing
OS Support for Flutter:
- Windows 7 SP1 or later (64-bit)
- macOS (64-bit)
- Linux (64-bit)
Required Knowledge
- A basic knowledge Programming
- A fair understanding of Mobile development and Imperative or Object Oriented Programming
- Basic knowledge of dependencies
Resources for Flutter and this Project:
- Flutter Website: https://flutter.io/
- Flutter Official Documentation: https://flutter.io/docs/
- Flutter Installation Information: https://flutter.io/get-started/install/
- Flutter GitHub repository: https://github.com/flutter/flutter
- Flutter Dart 2 Information: https://github.com/flutter/flutter/wiki/Trying-the-preview-of-Dart-2-in-Flutter
- Flutter Technical Overview: https://flutter.io/technical-overview/
- Dart Website: https://www.dartlang.org/
- Flutter Awesome GitHub Repository: https://github.com/Solido/awesome-flutter
- The Flutter Provider Library: https://github.com/rrousselGit/provider
- Pub website: https://pub.dartlang.org
Sources:
Flutter Logo (Google): https://flutter.io/
Difficulty
- Advanced
Description
In this flutter video tutorial, we take a look at one of the older projects; the geolocation weather application. In the nine months since this application was initially built, the main Geolocation flutter library was depreciated and dropped by its maintainer. As a result it has become completely incompatible with Dart 2.0 and Flutter's release candidate. Along with finding a new geolocation based Library for this application, we update the other dependencies, which includes removing old deprecated APIs.
Finding a replacement for Geolocation
When a library is abandoned by it's maintainer, there are a few options that a developer can take: they can replace the library, build their own replacement or fork the original library. Since the main idea of this application is centered around being able to determine the user's location a library like Geolocation is mandatory. The Dart community is fairly prolific and its ecosystem is rapidly changing therefore it makes sense to find a new library. We want this new library to have a similar API to the old Geolocation Library so that we don't have to make a large amount of changes to the business logic of our application. To locate a new library, we can make use of the Dart Packages website.
The new library that was chosen for this particular application is called Geolocator. This library has a very similar API to the other Geolocation library. It has the ability to give us location data via streams and futures. We also have the ability to modify the location accuracy along with a few other important options. The library gives us access to longitude and latitude values which is precisely what we need in this case. Above is the main logic for finding the GPS status and location using this library. As with before, we want to determine whether or not the application has access to location services. Afterwards, we also want to be able to then get a future with the new positional data inside of it.
Updating a Deprecated API
When this application was originally built, the RxCommand and RxWidget libraries were in their infancy. RxCommand featured a large amount of functions which determined the type of RxCommand that the user could create based on the input function. These originaly functions had names like async1
or sync3
based on whether or not the input function was asynchronous, had parameters, and had return values. After nine months and the release of Flutter 1.0, the API for this library has changed with the older functions being replaced.
In the above image, we can see some of the new RxCommand constructor names. Rather then name the constructors by number, there are more descriptive names. For example, if the input function doesn't contain any parameters, has a return type and is asynchronous, then the RxCommand constructor would be called createAsyncNoParam
. Also, each RxCommand function now features an optional canExecute
field to allow the developer to combine boolean observable with the resulting command stream. This new feature along with a plethora of other optional parameters gives the developer fine grain control over the RxCommands in a way that simply wasn't possible with the original API.
The Source Code for this video may be found here: https://github.com/tensor-programming/Weather_Tutorial/tree/tensor-programming-patch-4
Video Tutorial
Curriculum
Related Videos
- Building a Weather Application with Dart's Flutter Framework (Part 1, Handling Complex JSON with Built Code Generation)
- Building a Weather Application with Dart's Flutter Framework (Part 2, Creating a Repository and Model)
- Building a Weather Application with Dart's Flutter Framework (Part 3, RxCommand (RxDart) and Adding an Inherited Widget)
- Building a Weather Application with Dart's Flutter Framework (Part 4, Using RxWidget to Build a Reactive User Interface)
- Localize and Internationalize Applications with Intl and the Flutter SDK in Dart's Flutter Framework
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
Utopian Rocks Example
- Advanced Flutter Project - Setting Up the Basic Structure - Part One
- Advanced Flutter Project - Adding a Second BloC - Part Two
- Advanced Flutter Project - Best Practices - Generic BLoC Providers - Part Three
- Advanced Flutter Project - Adding Fonts and Fuzzy Timestamps - Part Four
- Advanced Flutter Project - Filtering Contributions and Building Aesthetics - Part Five
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
- Building a Mine Sweeper Game using Dart's Flutter Framework (Part 1)
- Building a Mine Sweeper Game using Dart's Flutter Framework (Part 2)
- Building a Mine Sweeper Game using Dart's Flutter Framework (Part 3)
- Building a Mine Sweeper Game using Dart's Flutter Framework (Part 4, Final)
Redux Todo App
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
- Playing Local, Network and YouTube Videos with the Video Player Plugin in Dart's Flutter Framework
- Building Custom Scroll Physics and Simulations with Dart's Flutter Framework
- Making Dynamic Layouts with Slivers in Dart's Flutter Framework
- Building a Sketch Application by using Custom Painters in Dart's Flutter Framework
- Using Dart Isolates, Dependency Injection and Future Builders in Dart's Flutter Framework
- Looking at the Main Features of the Beta Three Release of Dart's Flutter Framework
Great video tutorial @tensor. It is great to have a new piece from you.
I think it is important that we address issues like this one as they arise. Project owners and organizations are always discontinuing their support for various aspects of their projects. I appreciate you taking the time to address how the community can work around this issue.
Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.
To view those questions and the relevant answers related to your post, click here.
Need help? Chat with us on Discord.
[utopian-moderator]
Thanks @buckydurddle. I do agree that this is a fairly large concern. Its especially disconcerting when you are doing tutorials and they end up being deprecated along with the libraries. Fortunately, there are options to fixing these problems.
Thank you for your review, @buckydurddle! Keep up the good work!
This post has been voted on by the SteemSTEM curation team and voting trail in collaboration with @curie.
If you appreciate the work we are doing then consider voting both projects for witness by selecting stem.witness and curie!
For additional information please join us on the SteemSTEM discord and to get to know the rest of the community!
Hi, @tensor!
You just got a 5.12% upvote from SteemPlus!
To get higher upvotes, earn more SteemPlus Points (SPP). On your Steemit wallet, check your SPP balance and click on "How to earn SPP?" to find out all the ways to earn.
If you're not using SteemPlus yet, please check our last posts in here to see the many ways in which SteemPlus can improve your Steem experience on Steemit and Busy.
Hi @tensor!
Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server
Hey, @tensor!
Thanks for contributing on Utopian.
Congratulations! Your contribution was Staff Picked to receive a maximum vote for the video-tutorials category on Utopian for being of significant value to the project and the open source community.
We’re already looking forward to your next contribution!
Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).
Want to chat? Join us on Discord https://discord.gg/h52nFrV.
Vote for Utopian Witness!