Giter VIP home page Giter VIP logo

clima-flutter-completed's Introduction

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

clima-flutter-completed's People

Contributors

angelabauer avatar themuellenator avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

clima-flutter-completed's Issues

forming Custom variable for the "in" between weatherMessage and cityName

Hi this isn't really an issue but can i get samples on how to form the custom variable for the weatherMessage and cityName texts displayed after you create an exception to catch and check if the weatherData displays a null so as to display a different text.

I hope y'all get what I mean

A RenderFlex overflowed by 29 pixels on the bottom.

The relevant error-causing widget was:
Column file:///D:/FlutterApps/Clima-Flutter-master/lib/screens/location_screen.dart:60:18
The overflowing RenderFlex has an orientation of Axis.vertical.
The edge of the RenderFlex that is overflowing has been marked in the rendering with a yellow and black striped pattern. This is usually caused by the contents being too big for the RenderFlex.

Consider applying a flex factor (e.g. using an Expanded widget) to force the children of the RenderFlex to fit within the available space instead of being sized to their natural size.
This is considered an error condition because it indicates that there is content that cannot be seen. If the content is legitimately bigger than the available space, consider clipping it with a ClipRect widget before putting it in the flex, or using a scrollable container rather than a Flex, like a ListView.

The specific RenderFlex in question is: RenderFlex#d8db2 OVERFLOWING
... parentData: offset=Offset(0.0, 24.0) (can use size)
... constraints: BoxConstraints(w=411.4, h=377.1)
... size: Size(411.4, 377.1)
... direction: vertical
... mainAxisAlignment: spaceBetween
... mainAxisSize: max
... crossAxisAlignment: stretch
... verticalDirection: down
◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤
════════════════════════════════════════════════════════════════════════════════════════════════════

I followed all steps of tutorial, but still getting this error.

════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
The following _TypeError was thrown building Builder:
type 'int' is not a subtype of type 'double'

The relevant error-causing widget was: 
  MaterialApp file:///D:/Clients/experiments/Clima-Flutter/lib/main.dart:9:12
When the exception was thrown, this was the stack: 
#0      _LocationScreenState.updateUI.<anonymous closure> (package:clima/screens/location_screen.dart:36:14)
#1      State.setState (package:flutter/src/widgets/framework.dart:1233:30)
#2      _LocationScreenState.updateUI (package:clima/screens/location_screen.dart:28:5)
#3      _LocationScreenState.initState (package:clima/screens/location_screen.dart:24:5)
#4      StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4640:58)
...
════════════════════════════════════════════════════════════════════════════════════════════════════

Please help

_LoadingScreenState.initState() returned a Future. State.initState()

Exception caught by widgets library =======================================================
The following assertion was thrown building Builder:
_LoadingScreenState.initState() returned a Future.

State.initState() must be a void method without an async keyword.

Rather than awaiting on asynchronous work directly inside of initState, call a separate method to do this work without awaiting it.

The relevant error-causing widget was:
MaterialApp file:///E:/flutter_projects/Clima-Flutter/lib/main.dart:9:12
When the exception was thrown, this was the stack:

depreciated code

fg

when passing weather data , if you try to print anything from this data it says : instance of future deteced

Pressing back button takes to endless loading screen

The app starts with home page of loading screen and then navigates to location_screen.dart file. however, if you press the back button, it shows the loading screen which is endless and may make the user think that the app has crashed. One option is to put loading screen inside a widget rather than dart file or having double press back button to close the app but as a beginner, I do not know how to do it. i looked on stackoverflow but did not find any good answer.

Cant fetch the location even comapre to final/completed project

WhatsApp Image 2020-09-02 at 9 53 57 AM
WhatsApp Image 2020-09-02 at 9 52 51 AM

hi i got this error when try to get the location
i followed the code thil the end even i compare it with original completed project clima from london appbrewery
still didnt work . . u can see the following picture above even i ran it on the physical device . . from the picture u can see also that means it throw a same error (null value) didnt catch location properly. .

  1. first picture from repo london app brewery
    2.second picture is my repo that i code along with london app ### brewery

Use SetState ()

For dynamically changing the content of the location screen use set state() for getting weather details city wise

FlatButton(
onPressed: () async {
//WeatherModel modelx1 = WeatherModel();
var weatherData = await model.getlocationweather();
setState(() {
updateUI(weatherData);
});

                },
                child: Icon(
                  Icons.near_me,
                  size: 30.0,
                ),
              ),

Assertion failed

Assertion failed: file:///C:/Users/User/flutter/packages/flutter/lib/src/widgets/navigator.dart:5307:12
!_debugLocked
is not true

Does anyone know why this happens?
I did all the steps right but still it crashes after it loads.

Recompile with -Xlint

just clone this repo and run on android studio and run into following error.

Note: C:\src\flutter\flutter.pub-cache\hosted\pub.dartlang.org\permission_handler-3.3.0\android\src\main\java\com\baseflow\permissionhandler\PermissionHandlerPlugin.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.

and followed by built with 401 response code .

Error

It is not syncing files with android

Build failed with an exception

when i run the app, build failed with this exception ::

FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring root project 'android'.

Could not resolve all artifacts for configuration ':classpath'.
Could not resolve com.google.gms:google-services:4.2.0.
Required by:
project :
> Could not resolve com.google.gms:google-services:4.2.0.

App not running on real device even it’s successfully installed

I installed the clima weather detection app on android
I enabled the location services in the mobile as well as the app.
But it’s not moving forward to the loading page
It’s stuck on that loading screen
Do I need to provide api nearer to my country ?? Or something else. Please help me on this

After build the apk and try to open it on phone, it stuck on the loading Screen

After build the apk and try to open it on phone, it stuck on the loading Screen, on console I get this error-
" E/flutter (21270): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: SocketException: Failed host lookup: 'api.openweathermap.org' (OS Error: No address associated with hostname, errno = 7)
E/flutter (21270): "

I checked the internet and added these 2 line manually-
uses-permission android:name="android.permission.INTERNET"
uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"

I already gave the permission to the app to access the internet on my phone. But still no luck. I checked the Api link- it's perfect on issue on it.
Any solution??

followed the ful tutorial but i am getting this error

══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
The following assertion was thrown building LocationScreen(dirty, state:
_LocationScreenState#8c194):
A non-null String must be provided to a Text widget.
'package:flutter/src/widgets/text.dart':
Failed assertion: line 360 pos 10: 'data != null'

The relevant error-causing widget was:
LocationScreen
file:///G:/app%20brewery%20flutter/savd%20projects/weather_forcasting_app/lib/screens/loading_screen.dart:26:15

When the exception was thrown, this was the stack:
#2 new Text (package:flutter/src/widgets/text.dart:360:10)
#3 _LocationScreenState.build (package:weather_forcasting_app/screens/location_screen.dart:103:21)
#4 StatefulElement.build (package:flutter/src/widgets/framework.dart:4663:28)
#5 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4546:15)
#6 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4719:11)
#7 Element.rebuild (package:flutter/src/widgets/framework.dart:4262:5)
#8 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:4525:5)
#9 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4710:11)
#10 ComponentElement.mount (package:flutter/src/widgets/framework.dart:4520:5)
... Normal element mounting (132 frames)
#142 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3490:14)
#143 Element.updateChild (package:flutter/src/widgets/framework.dart:3258:18)
#144 RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:5624:32)
#145 MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6001:17)
#146 Element.updateChild (package:flutter/src/widgets/framework.dart:3245:15)
#147 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4571:16)
#148 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4719:11)
#149 Element.rebuild (package:flutter/src/widgets/framework.dart:4262:5)
#150 StatefulElement.update (package:flutter/src/widgets/framework.dart:4751:5)
#151 Element.updateChild (package:flutter/src/widgets/framework.dart:3245:15)
#152 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4571:16)
#153 Element.rebuild (package:flutter/src/widgets/framework.dart:4262:5)
#154 ProxyElement.update (package:flutter/src/widgets/framework.dart:4906:5)
#155 _InheritedNotifierElement.update (package:flutter/src/widgets/inherited_notifier.dart:183:11)
#156 Element.updateChild (package:flutter/src/widgets/framework.dart:3245:15)
#157 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5881:14)
#158 Element.updateChild (package:flutter/src/widgets/framework.dart:3245:15)
#159 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4571:16)
#160 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4719:11)
#161 Element.rebuild (package:flutter/src/widgets/framework.dart:4262:5)
#162 StatefulElement.update (package:flutter/src/widgets/framework.dart:4751:5)
#163 Element.updateChild (package:flutter/src/widgets/framework.dart:3245:15)
#164 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5881:14)
#165 Element.updateChild (package:flutter/src/widgets/framework.dart:3245:15)
#166 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5881:14)
#167 Element.updateChild (package:flutter/src/widgets/framework.dart:3245:15)
#168 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4571:16)
#169 Element.rebuild (package:flutter/src/widgets/framework.dart:4262:5)
#170 StatelessElement.update (package:flutter/src/widgets/framework.dart:4627:5)
#171 Element.updateChild (package:flutter/src/widgets/framework.dart:3245:15)
#172 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4571:16)
#173 Element.rebuild (package:flutter/src/widgets/framework.dart:4262:5)
#174 ProxyElement.update (package:flutter/src/widgets/framework.dart:4906:5)
#175 Element.updateChild (package:flutter/src/widgets/framework.dart:3245:15)
#176 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4571:16)
#177 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4719:11)
#178 Element.rebuild (package:flutter/src/widgets/framework.dart:4262:5)
#179 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2667:33)
#180 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:866:20)
#181 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:286:5)
#182 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1117:15)
#183 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1056:9)
#184 SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:972:5)
#188 _invoke (dart:ui/hooks.dart:253:10)
#189 _drawFrame (dart:ui/hooks.dart:211:3)
(elided 5 frames from class _AssertionError and dart:async)

════════════════════════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
The following assertion was thrown building LocationScreen(dirty, state: _LocationScreenState#8c194):
A non-null String must be provided to a Text widget.
'package:flutter/src/widgets/text.dart':
Failed assertion: line 360 pos 10: 'data != null'

The relevant error-causing widget was:
LocationScreen file:///G:/app%20brewery%20flutter/savd%20projects/weather_forcasting_app/lib/screens/loading_screen.dart:26:15
When the exception was thrown, this was the stack:
#2 new Text (package:flutter/src/widgets/text.dart:360:10)
#3 _LocationScreenState.build (package:weather_forcasting_app/screens/location_screen.dart:103:21)
#4 StatefulElement.build (package:flutter/src/widgets/framework.dart:4663:28)
#5 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4546:15)
#6 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4719:11)
...
════════════════════════════════════════════════════════════════════════════════════════════════════
i need help

deprecated geolocator dependancy

in the tutorial the code didnt work for me so i used this instead import 'package:flutter/material.dart';
import 'package:geolocator/geolocator.dart';
class LoadingScreen extends StatefulWidget {
@OverRide
_LoadingScreenState createState() => _LoadingScreenState();
}

class _LoadingScreenState extends State {
Future getCurrentPosition() async {
// Check if the location service is enabled
bool serviceEnabled = await Geolocator.isLocationServiceEnabled();
print("Location service enabled: $serviceEnabled");
if (!serviceEnabled) {
return Future.error("Location service is not enabled.");
}

// Check if the location permission is granted
LocationPermission status = await Geolocator.checkPermission();
print("Location permission: $status");
if (status == LocationPermission.denied) {
  // Request the location permission
  status = await Geolocator.requestPermission();
  if (status == LocationPermission.denied) {
    // Permission is not granted, return an error message
    return Future.error("Location permission not granted.");
  }
}

// Get the current position if the location permission is granted
Position position = await Geolocator.getCurrentPosition(
    desiredAccuracy: LocationAccuracy.high);

print(position);
return position;

}

@OverRide
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: ElevatedButton(
onPressed: () {
getCurrentPosition();
},
child: Text('Get Location'),
),
),
);
}
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.