Starter code for the Clima Project from the Complete Flutter Development Bootcamp

Overview

App Brewery Banner

Clima

Our Goal

The objective of this tutorial is to learn about asynchronous programming in Dart. We'll look at how to carry out time consuming tasks such as getting device location and networking to get data from the internet.

What you will create

We’re going to make a weather app inspired by the beautiful designs made by Olia Gozha. By the end of the module, you'll be able to find out the live weather data in the current location of the device as well as the weather for any city you can think of!

Finished App

What you will learn

  • How to use Dart to perform asynchronous tasks.
  • Understand async and await.
  • Learn about Futures and how to work with them.
  • How to network with the Dart http package.
  • What APIs are and how to use them to get data from the internet.
  • What JSONs are and how to parse them using the Dart convert package.
  • How to pass data forwards and backwards between screens using the Navigator.
  • How to handle exceptions in Dart using try/catch/throw.
  • Learn about the lifecycle of Stateful Widgets and how to override them.
  • How to use the Geolocator package to get live location data for both iOS and Android.
  • How to use the TextField Widget to take user input.

This is a companion project to The App Brewery's Complete Flutter Development Bootcamp, check out the full course at www.appbrewery.co

End Banner

Comments
  • Error on Gathering API data using variables

    Error on Gathering API data using variables

    I am getting the API response when i put hardcoded values in Lon and lat but whenever i replace it with the variables that i declared it gives me the error 400. I have tried very hard to solve this but in vain kindly some one help me regarding this.

    The code is here:

    ` void getData() async { var response = await http.get(Uri.parse( 'https://api.openweathermap.org/data/2.5/weather?lat=$latitude&lon=$longitude&appid=2a2ebb0a274ae93918a45df74879b8d6', )); if (response.statusCode == 200) { String data = response.body; var decodedData = jsonDecode(data);

      double temperature = decodedData['main']['temp'];
      int condition = decodedData['weather'][0]['id'];
      String cityName = decodedData['name'];
      print(temperature);
      print(condition);
      print(cityName);
    } else {
      print(response.statusCode);
    }
    

    }`

    opened by malikdanishalii 1
  • 'position' isn't printed

    'position' isn't printed

    Hi,

    I have the same code as in the tutorials. I also did a project update to Flutter 2.2.3 as described in one of the PRs. But, before and after the update the position isn't printed, the app just builds, and after a click on the 'get Location' button location isn't printed. Even when I moved getLocation() call to the init method, nothing happens after the app loads - the position isn't printed. Anyone else had this issue maybe?

    opened by bokiperic 1
  • Failed to navigate to location_screen.dart on app restart

    Failed to navigate to location_screen.dart on app restart

    I get this whenever I restart the app

    W/ppbrewery.clim(24486): Verification of void com.google.android.gms.common.internal.zzc.() took 158.180ms

    1. I've already added the SpinKit package
    2. I waited for the getLocation() method to run

    I'm stuck at the loading_screen with the spinner rolling info

    Screenshot (39)

    opened by Devlonoah 1
  • Open Weather API crashing when getting data

    Open Weather API crashing when getting data

    My code works perfectly with the sample link, but as soon as I try the API URL it crashes, I thought it was an error with the http package so I tried an alternative called Dio, but still crashes.

    The correct URL is https://api.openweathermap.org/data/2.5/weather?lat=-38.115958&lon=176.2232279&appid=ab049c97d78636ee1e507a36cc400930 which works perfectly.

    Here's my code:

    import 'dart:convert' as convert;
    import 'package:flutter/material.dart';
    import 'package:clima/services/location.dart';
    import 'package:dio/dio.dart';
    
    const apiKey = 'ab049c97d78636ee1e507a36cc400930';
    
    class LoadingScreen extends StatefulWidget {
      @override
      _LoadingScreenState createState() => _LoadingScreenState();
    }
    
    class _LoadingScreenState extends State<LoadingScreen> {
    
          double latitude;
          double longitude;
    
       void getLocation() async {
    
         Location currentLocation = Location();
    
         await currentLocation.getCurrentLocation();
         latitude = currentLocation.latitude;
         longitude = currentLocation.longitude;
    
       }
    
       void getData() async {
         var url = 'https://api.openweathermap.org/data/2.5/weather?lat=$latitude&lon=$longitude&appid=$apiKey';
         Response jsonResponse = await Dio().get(url);
          if (jsonResponse.statusCode == 200){
    
            var decodedData = convert.jsonDecode(jsonResponse.toString());
    
           int condition = decodedData['weather'][0]['id'];
           double temperature = decodedData['main']['temp'];
           String cityName = decodedData['name'];
           print(cityName);
           print(temperature);
           print(condition);
           print(latitude);
           print(longitude);
    
    
    
          } else {
            print(jsonResponse.statusCode);
          }
       }
    
    
      @override
      void initState(){
        super.initState();
          getLocation();
          getData();
      }
    
    
      @override
      Widget build(BuildContext context) {
        return Scaffold();
      }
    }
    

    Here is the error:

    Performing hot restart... Syncing files to device SM G955F... Restarted application in 1,636ms. E/flutter ( 9434): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: DioError [DioErrorType.RESPONSE]: Http status error [400] E/flutter ( 9434): #0 DioMixin._dispatchRequest (package:dio/src/dio.dart:963:7) E/flutter ( 9434): E/flutter ( 9434): #1 DioMixin._request._interceptorWrapper... (package:dio/src/dio.dart:849:37) E/flutter ( 9434): #2 DioMixin.checkIfNeedEnqueue (package:dio/src/dio.dart:1118:22) E/flutter ( 9434): #3 DioMixin._request._interceptorWrapper.. (package:dio/src/dio.dart:846:22) E/flutter ( 9434): #4 new Future. (dart:async/future.dart:176:37) E/flutter ( 9434): #5 _rootRun (dart:async/zone.dart:1122:38) E/flutter ( 9434): #6 _CustomZone.run (dart:async/zone.dart:1023:19) E/flutter ( 9434): #7 _CustomZone.runGuarded (dart:async/zone.dart:925:7) E/flutter ( 9434): #8 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:965:23) E/flutter ( 9434): #9 _rootRun (dart:async/zone.dart:1126:13) E/flutter ( 9434): #10 _CustomZone.run (dart:async/zone.dart:1023:19) E/flutter ( 9434): #11 _CustomZone.bindCallback. (dart:async/zone.dart:949:23) E/flutter ( 9434): #12 Timer._createTimer. (dart:async-patch/timer_patch.dart:23:15) E/flutter ( 9434): #13 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:384:19) E/flutter ( 9434): #14 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:418:5) E/flutter ( 9434): #15 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12) E/flutter ( 9434):

    opened by jobsyNZ 1
  • NoSuchMethodError

    NoSuchMethodError

    I am geeting nosuchmethoderror.I have copied the code . but getting this error. ════════ Exception caught by widgets library ═══════════════════════════════════════════════════════ The following NoSuchMethodError was thrown building Builder: The method '[]' was called on null. Receiver: null Tried calling:

    The relevant error-causing widget was: MaterialApp file:///C:/Users/shiva/AndroidStudioProjects/Clima-Flutter/lib/main.dart:9:12 When the exception was thrown, this was the stack: #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5) #1 _LocationScreenState.update. (package:clima/screens/location_screen.dart:26:25) #2 State.setState (package:flutter/src/widgets/framework.dart:1267:30) #3 _LocationScreenState.update (package:clima/screens/location_screen.dart:25:5) #4 _LocationScreenState.initState (package:clima/screens/location_screen.dart:21:5) ... ════════════════════════════════════════════════════════════════════════════════════════════════════ E/UIFirst (23085): failed to open /proc/23085/stuck_info, No such file or directory Lost connection to device. error

    opened by shivamkg0604 0
  • Error: NoSuchMethodError: The getter 'latitude' was called on null.

    Error: NoSuchMethodError: The getter 'latitude' was called on null.

    Hello Angela, I am facing some unexpected error in this refactor challenge of clima app. In the video tutorial there is no error in the console, but when in my case its showing NoSuchMethodError: The getter 'latitude' was called on null. I am attaching 2 pictures, maybe that can help. 1 2

    please help

    opened by roy2904 0
  • Unable to Clone

    Unable to Clone

    Unable to clone this repository in Android studio....

    early EOF the remote end hung up unexpectedly index-pack failed RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054

    This is the error i'm currently dealing with in my android studio while cloning this repository

    opened by IEIrodov 0
  • I have issue in getlocationData() method using Navigator.push of LocationScreen();

    I have issue in getlocationData() method using Navigator.push of LocationScreen();

    while using Navigator.push of loadingScreen

    Error :'Do not use BuildContext of async gaps'

    void getLocationData() async { Location location = Location(); await location.getCurrentLocation(); longitude = location.longitude; latitude = location.latitude;

    NetworkHelper networkHelper = NetworkHelper(
        'https://api.openweathermap.org/data/2.5/weather?lat=$latitude&lon=$longitude&appid=$apiKey');
    
    var weatherData = await networkHelper.getData();
    
    Navigator.push(context, MaterialPageRoute(builder: (context){
      return LocationScreen();
      
    }));
    

    }

    opened by Midhunap 0
  • Problem when i click on get weather

    Problem when i click on get weather

    It receives the value but dosen't show in the location screen in the console it says Future has no instance [] Maybe we have to change something in the getCityLocation()?

    opened by Saimonkabir 0
  • everyone who are facing location denied problem and did not find position here is the solution welcome in advance :)

    everyone who are facing location denied problem and did not find position here is the solution welcome in advance :)

    https://gist.github.com/tauheed0007/990796af7ba921a9b914945e98341f38

    this will help you just check and if you have any question feel free to ask on my gist i will reply you all

    opened by tauheed0007 1
  • Make it it work for current android (api 32) and flutter 2.10.3

    Make it it work for current android (api 32) and flutter 2.10.3

    I also upgraded gradle and sdk version to make all warnings like Warning: Mapping new ns http://schemas.android.com/repository/android/common/02 to old ns http://schemas.android.com/repository/android/common/01 go away

    To use it before this PR is merged:

    git clone https://github.com/londonappbrewery/Clima-Flutter.git cd Clima-Flutter git pull origin pull/31/head

    Or directly clone my repo: https://github.com/philippkeller/Clima-Flutter

    opened by philippkeller 1
  • Permission denied error

    Permission denied error

    I am getting several error in AndroidManifuest.xml file and unable to proceed further on the project. I am currently learning the course from my organisation id. The below was the issue I m getting. I have tried to resolve by googling and various ways but nothing helped. I am struck and unable to move forward on the same. Screenshot 2022-01-09 at 7 25 33 AM .

    @angelabauer @TheMuellenator

    opened by Ahamed4 6
Owner
London App Brewery
The Best Programming School in the World
London App Brewery
Learn to Code While Building Apps - The Complete Flutter Development Bootcamp

BMI Calculator ?? Our Goal The objective of this tutorial is to look at how we can customise Flutter Widgets to achieve our own beautiful user interfa

London App Brewery 146 Jan 1, 2023
Learn to Code While Building Apps - The Complete Flutter Development Bootcamp

Quizzler ❓ Our Goal In this tutorial we will be reviewing Stateful and Stateless Widgets as well as learning about the fundamental building blocks of

London App Brewery 169 Dec 31, 2022
Starter-Flutter - Starter flutter project for best architecture and seperation of code

Modular-Architecture Codebase CodeBase , Infrastructure and the common Layers (c

Ahmed Tawfiq 13 Feb 16, 2022
Encode App-Dev is a open source project which contains different projects of Application development, Android development, IOS development, Flutter, Kotlin, Dart, Java, Swift etc.

HACKTOBERFEST 2022 Encode App-Dev is an open source project which contains different projects of Application development, Android development, IOS dev

null 4 Dec 4, 2022
A starter kit for beginner learns with Bloc pattern, RxDart, sqflite, Fluro and Dio to architect a flutter project. This starter kit build an App Store app as a example

Flutter Starter Kit - App Store Example A starter kit for beginner learns with Bloc pattern, RxDart, sqflite, Fluro and Dio to architect a flutter pro

kw101 678 Jan 8, 2023
flutter development bootcamp layout challenge #2.1

MiCard App Challenge Hey folks! This app is the continuation of the layout_challenge_app. I coded this app from scratch because unfortunate things hap

Damla Çim 1 Jan 6, 2022
Project-x2 - A Flutter E-Commerce starter template that bootstraps development of your mobile application

Flutter E-Commerce UI KIT A powerful Flutter E-Commerce starter template that bo

null 1 Apr 7, 2022
bootcamp flutter beginner Kuldi Project week 2

tugasweek2 A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if th

null 0 Nov 27, 2021
Production-grade project developed during the Reso Coder Academy Flutter Bootcamp: It's a mobile Github repository viewer

RepoStar - GitHub Starred Repository Manager Production-grade project developed during the Reso Coder Academy Flutter Bootcamp. It's a mobile Github s

Kishan Dhankecha 4 Aug 18, 2022
Starter project for Flutter plugins willing to access native and synchronous rust code using FFI

Flutter Rust FFI Template This project is a Flutter Plugin template. It provides out-of-the box support for cross-compiling native Rust code for all a

Jør∂¡ 561 Dec 7, 2022
A flutter plugin about qr code or bar code scan , it can scan from file、url、memory and camera qr code or bar code .Welcome to feedback your issue.

r_scan A flutter plugin about qr code or bar code scan , it can scan from file、url、memory and camera qr code or bar code .Welcome to feedback your iss

PengHui Li 112 Nov 11, 2022
Techcareer.net Flutter Bootcamp Bitirme Projesi

foodie Techcareer.net Flutter Bootcamp Bitirme Projem olan Foodie, bir yemek sipariş uygulamasıdır. Bu projeyi gerçekleştirirken kullandığım yapılar;

Lütfiye Yaşar 4 Oct 3, 2022
Flutter firebase starter project

Flutter Firebase Starter project Made with ?? from Nepal A project you can clone to build your next project with Flutter with Firebase services. What

Damodar Lohani 262 Dec 29, 2022
Flutterstarterproject - Clean Architecture Flutter starter project, using tdd + bloc

Flutter Starter Project Generated by the Nero Lab CLI ?? A Nero Lab Project crea

Muhammad Noerhidayatullah 12 Dec 8, 2022
Flutter starter project - boilerPlate for Clean Architecture with Domain-Driven-Design with commonly used dependencies

flutter_starter_project A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you

MJ Montes 0 Jan 2, 2022
Code, Exercises & Syllabus for my Complete Dart Course

Dart Course | Code With Andrea This repo contains all the exercises and solutions from my Dart Course. Course Syllabus 1. Introduction Making the most

Andrea Bizzotto 244 Dec 30, 2022
Quickly is build as a tool to enhance your Flutter UI development experience and make code easier

Quickly is build as a tool to enhance your Flutter UI development experience and make code easier. It is highly inspired by Bootstrap and Tailwind CSS. It also provide lots of extension methods on String, List and Map.

Aniket Khote 11 Oct 24, 2022
Udemy Course "Dart and Flutter: The Complete Developer's Guide" Project. (With Hive DB)

Udemy-Course-Flutter Udemy Course "Dart and Flutter: The Complete Developer's Guide" Project. (With Hive DB) The course: https://www.udemy.com/course/

Muhammad Tayyab 1 Jun 11, 2022
School Project to complete a course,uses a python backend and a flutter frontend

hit_400_app Getting Started This project is a starting point for a Flutter application. #Run flutter packages get #Run the python main.py after instal

null 0 Dec 28, 2021