Fixing an App with a Deprecated Library and API - Weather App Part 5

in #utopian-io5 years ago

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:
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:

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.

dart-geo.png

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.

rxCommand.png

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

Projects and Series

Stand Alone Projects:
Utopian Rocks Example
Building a Calculator
Movie Searcher Application

Minesweeper Game

Redux Todo App

Curriculum

Proof of Work Done

https://github.com/tensor-programming

Sort:  

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!

Coin Marketplace

STEEM 0.18
TRX 0.14
JST 0.029
BTC 57849.42
ETH 3122.29
USDT 1.00
SBD 2.43