londonappbrewery / clima-flutter Goto Github PK
View Code? Open in Web Editor NEWStarter code for the Clima Project from the Complete Flutter Development Bootcamp
Home Page: https://www.appbrewery.co
Starter code for the Clima Project from the Complete Flutter Development Bootcamp
Home Page: https://www.appbrewery.co
It also shows me the default location(of the android emulator), but I noticed in the console that I get this error:
E/flutter (19578): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: NoSuchMethodError: Class 'Future' has no instance method '[]'.
E/flutter (19578): Receiver: Instance of 'Future'
E/flutter (19578): Tried calling:
this is my getCityWeather method:
Future getCityWeather(String cityName) async {
NetworkHelper networkHelper = NetworkHelper('$openWeatherMapURL?q=$cityName&appid=$apiKey&units=metric');
var weatherData = await networkHelper.getData();
return weatherData;
}
please help me, I really want to finish this project already.
Hello!
the print lines in the following part of "loading_screen.dart" code unable to be printed:
` void getData() async {
http.Response response = await http.get(
'https://api.openweathermap.org/data/2.5/onecall?lat=$latitude&lon=$longitude&appid=$apiKey');
if (response.statusCode == 200) {
Map decodeData = json.decode(response.body);
double temperature = decodeData['main']['temp'];
int conditionNumber = decodeData['weather'][0]['id'];
String cityName = decodeData['name'];
print(temperature);
print(conditionNumber);
print(cityName);
} else {
print(response.statusCode);
}
}`
Sometimes nothing printed into the console and sometimes the problem appeared.
Also the following lines appeared:
"W/ppbrewery.clim(25370): Accessing hidden method Landroid/content/Context;->getFeatureId()Ljava/lang/String; (greylist, reflection, allowed)"
Hope the problem can be solved
Thanks
I have tried searching about this issue extensively but I could not find an answer.
My Clima App refuses to give me the geolocation. The geolocator package does not seem to work. I am really confused about this.
The error I get is :
I/art ( 6109): at void android.os.MessageQueue.nativePollOnce(long, int) (MessageQueue.java:-2)
I/art ( 6109): at android.os.Message android.os.MessageQueue.next() (MessageQueue.java:328)
I/art ( 6109): at void android.os.Looper.loop() (Looper.java:148)
I/art ( 6109): at void android.app.ActivityThread.main(java.lang.String[]) (ActivityThread.java:6251)
I/art ( 6109): at java.lang.Object java.lang.reflect.Method.invoke!(java.lang.Object, java.lang.Object[]) (Method.java:-2)
I/art ( 6109): at void com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run() (ZygoteInit.java:1075)
I/art ( 6109): at void com.android.internal.os.ZygoteInit.main(java.lang.String[]) (ZygoteInit.java:936)
I/art ( 6109):
E/flutter ( 6109): [ERROR:flutter/shell/platform/android/platform_view_android_jni.cc(39)] java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/util/ArraySet;
E/flutter ( 6109): at com.google.android.gms.common.api.internal.GoogleApiManager.(Unknown Source)
E/flutter ( 6109): at com.google.android.gms.common.api.internal.GoogleApiManager.zab(Unknown Source)
E/flutter ( 6109): at com.google.android.gms.common.api.GoogleApi.(Unknown Source)
E/flutter ( 6109): at com.google.android.gms.common.api.GoogleApi.(Unknown Source)
E/flutter ( 6109): at com.google.android.gms.location.FusedLocationProviderClient.(Unknown Source)
E/flutter ( 6109): at com.google.android.gms.location.LocationServices.getFusedLocationProviderClient(Unknown Source)
E/flutter ( 6109): at com.baseflow.geolocator.tasks.LocationUpdatesUsingLocationServicesTask.(LocationUpdatesUsingLocationServicesTask.java:29)
E/flutter ( 6109): at com.baseflow.geolocator.tasks.TaskFactory.createCurrentLocationTask(TaskFactory.java:44)
E/flutter ( 6109): at com.baseflow.geolocator.GeolocatorPlugin.onMethodCall(GeolocatorPlugin.java:66)
E/flutter ( 6109): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:222)
E/flutter ( 6109): at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:96)
E/flutter ( 6109): at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:656)
E/flutter ( 6109): at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter ( 6109): at android.os.MessageQueue.next(MessageQueue.java:328)
E/flutter ( 6109): at android.os.Looper.loop(Looper.java:148)
E/flutter ( 6109): at android.app.ActivityThread.main(ActivityThread.java:6251)
E/flutter ( 6109): at java.lang.reflect.Method.invoke(Native Method)
E/flutter ( 6109): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1075)
E/flutter ( 6109): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
E/flutter ( 6109): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.util.ArraySet" on path: DexPathList[[zip file "/data/app/com.example.geol-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.geol-1/lib/arm, /data/app/com.example.geol-1/base.apk!/lib/armeabi-v7a, /system/lib, /vendor/lib, /system/vendor/lib]]
E/flutter ( 6109): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
E/flutter ( 6109): at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
E/flutter ( 6109): at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
E/flutter ( 6109): ... 19 more
E/flutter ( 6109):
F/flutter ( 6109): [FATAL:flutter/shell/platform/android/platform_view_android_jni.cc(76)] Check failed: CheckException(env).
F/libc ( 6109): Fatal signal 6 (SIGABRT), code -6 in tid 6109 (om.example.geol)
Lost connection to device.
Exited (sigterm)
import 'dart:convert';
import 'package:clima/services/location.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
const KapiKey = '1c7a174d6a5d41f17e6f08959deecf2d';
class LoadingScreen extends StatefulWidget {
@OverRide
_LoadingScreenState createState() => _LoadingScreenState();
}
class _LoadingScreenState extends State {
double latitude;
double longtiude;
@OverRide
void initState() {
// TODO: implement initState
super.initState();
getLocation();
// if i place getData() here only then it gets called.
}
void getLocation() async {
Location location = Location();
print('hi'); //this will prin
print('hi'); // this also will print
await location.getCurrentLocation();
print('hi'); this will not print.
latitude = location.lat;
longtiude = location.long;
getData(); doesnot get called at all!
}
void getData() async {
http.Response response = await http.get(
'http://api.openweathermap.org/data/2.5/weather?lat=$latitude&lon=$longtiude&appid=$KapiKey');
if (response.statusCode == 200) {
String data = response.body;
print(data);
var DecodedData = jsonDecode(data);
double tempreture = DecodedData['main']['temp'];
int condition = DecodedData['weather'][0]['id'];
String cityName = DecodedData['name'];
print(tempreture);
print(condition);
print(cityName);
} else {
print(response.statusCode);
}
}
@OverRide
Widget build(BuildContext context) {
return Scaffold(
body: Center(),
);
}
}
after updating the manifest as explained I get this error when I click the button -
copy from the manifest:
<permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
this is the error I get:
E/flutter (10219): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: No location permissions are defined in the manifest. Make sure at least ACCESS_FINE_LOCATION or ACCESS_COARSE_LOCATION are defined in the manifest.
I tried to copy the git project to a new project but I get the same error
can you help me ?
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();
}));
}
So anytime I try to import any project from the course resource I am being told to migrate the project; #
Warning
──────────────────────────────────────────────────────────────────────────────
Your Flutter application is created using an older version of the Android
embedding. It's being deprecated in favor of Android embedding v2. Follow the
steps at
https://flutter.dev/go/android-project-migration
to migrate your project.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
but when I follow the instructions and run the app it takes long, i.e. Running Gradle Task takes long than usual and I mean too long. so I ignore it, but i keep getting the warning to migrate project what do I do
Hello Angela,
I really enjoy your course (Lynda.com) but I think something doesn't work (after an update ? Xcode, android studio, I have no idea what's the reason)
It seems the icon is not displayed on the iPhone X emulator but it works on the pixel 3:
I took 2 pictures, maybe that can help :)
Thank you for the course 👍
I am getting the following error after adding the geolocator package to my project.
Launching lib/main.dart on iPhone 11 Pro Max in debug mode...
Upgrading project.pbxproj
Legacy build system detected, removing /Users/xxxxxxxxxxxxxxx/Documents/development/android_studio_projects/Clima-Flutter/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings
Project base configurations detected, removing.
Warning: CocoaPods not installed. Skipping pod install.
CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/platform-plugins
To install see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.
CocoaPods not installed or not in valid state.
Error launching application on iPhone 11 Pro Max.
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
void getLocationData() async {
Location location = Location();
await location.getCurrentLocation();
latitude = location.latitude;
longitude = location.longitude;
NetworkHelper networkHelper = NetworkHelper(
url:
'https://api.openweathermap.org/data/2.5/weather?lat=$latitude&lon=$longitude&appid=$apiKey&units=metric');
var weatherData = await networkHelper.getData();
Navigator.push(context, MaterialPageRoute(builder: (context) {
return LocationScreen(
locationWeather: weatherData,
);
}));
}
class NetworkHelper {
NetworkHelper({this.url});
final String url;
Future<void> getData() async {
http.Response response = await http.get(url);
if (response.statusCode == 200) {
String data = response.body;
return jsonDecode(data);
} else {
return (response.statusCode);
}
}
}
lib/screens/loading_screen.dart:37:26: Error: This expression has type 'void' and can't be used.
locationWeather: weatherData,
In the video tutorial there is no error popping up, but when in my case the error this expression has a void and can't be used is there
Some help, please!
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);
}
}`
hello, i am new in this flutter, and i wanna make chatbot app with stt and tts inside it. but i got error in this and i don;t khow what todo, please help me
`class _MyApppState extends State {
stt.SpeechToText _speech;
bool _isListening = false;
String _text = "";
String speak;
String qry;
@OverRide
void initState() {
super.initState();
_speech = stt.SpeechToText();
}
final FlutterTts flutterTts = FlutterTts();
void response(query) async {
AuthGoogle authGoogle =
await AuthGoogle(fileJson: "assets/newagent-kalbgl-c0fb323bfb4c.json")
.build();
Dialogflow dialogflow =
Dialogflow(authGoogle: authGoogle, language: Language.indonesian);
AIResponse aiResponse = await dialogflow.detectIntent(query);
setState(() {
messsages.insert(0, {
"data": 0,
"message": aiResponse.getListMessage()[0]["text"]["text"][0].toString()
});
});
print(aiResponse.getListMessage()[0]["text"]["text"][0].toString());
}
void _speak(query) async {
print(await flutterTts.getLanguages);
await flutterTts.setLanguage('jv-ID');
await flutterTts.speak(query);
}
final messageInsert = TextEditingController();
List messsages = List();
@OverRide
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(
"Jawa Bot",
),
backgroundColor: Colors.blueGrey,
),
body: Container(
child: Column(children: [
Center(
child: Container(
padding: EdgeInsets.only(top: 15, bottom: 10),
child: Text(
"Dinten Niki, ${DateFormat("Hm").format(DateTime.now())}",
style: TextStyle(fontSize: 15),
),
),
),
Flexible(
child: ListView.builder(
reverse: true,
padding: EdgeInsets.all(10.0),
itemCount: messsages.length,
itemBuilder: (context, index) => chat(
messsages[index]["message"].toString(),
messsages[index]["data"]))),
SizedBox(
height: 20,
),
Divider(
height: 5.0,
color: Colors.greenAccent,
),
Container(
child: ListTile(
leading: IconButton(
icon: Icon(
_isListening ? Icons.mic : Icons.mic_none,
color: Colors.greenAccent,
size: 35,
),
onPressed: () {
_listen();
if (_text.isEmpty) {
print("empty message");
} else {
setState(() {
messsages.insert(0, {"data": 1, "message": _text});
});
speak = response(_text);
_speak(speak);
_text = '';
}
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
},
),
title: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(15)),
color: Color.fromRGBO(220, 220, 220, 1)),
padding: EdgeInsets.only(left: 15),
child: Row(
children: [
Flexible(
child: TextField(
controller: messageInsert,
decoration: InputDecoration(
hintText: "Send Your Message",
hintStyle: TextStyle(color: Colors.black26),
border: InputBorder.none,
focusedBorder: InputBorder.none,
enabledBorder: InputBorder.none,
errorBorder: InputBorder.none,
disabledBorder: InputBorder.none,
),
style: TextStyle(fontSize: 16, color: Colors.black),
)),
],
),
),
trailing: IconButton(
icon: Icon(Icons.send, size: 30, color: Colors.greenAccent),
onPressed: () {
if (messageInsert.text.isEmpty) {
print("empty message");
} else {
setState(() {
messsages.insert(
0, {"data": 1, "message": messageInsert.text});
});
response(messageInsert.text);
_speak(messageInsert.text);
messageInsert.clear();
}
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
}),
)),
SizedBox(
height: 15.0,
)
]),
));
}`
`oid response(query) async {
AuthGoogle authGoogle =
await AuthGoogle(fileJson: "assets/newagent-kalbgl-c0fb323bfb4c.json")
.build();
Dialogflow dialogflow =
Dialogflow(authGoogle: authGoogle, language: Language.indonesian);
AIResponse aiResponse = await dialogflow.detectIntent(query);
setState(() {
messsages.insert(0, {
"data": 0,
"message": aiResponse.getListMessage()[0]["text"]["text"][0].toString()
});
});
print(aiResponse.getListMessage()[0]["text"]["text"][0].toString());
}
void _speak(query) async {
print(await flutterTts.getLanguages);
await flutterTts.setLanguage('jv-ID');
await flutterTts.speak(query);
}
`
onPressed: () { _listen(); if (_text.isEmpty) { print("empty message"); } else { setState(() { messsages.insert(0, {"data": 1, "message": _text}); }); speak = response(_text); _speak(speak); _text = ''; } FocusScopeNode currentFocus = FocusScope.of(context); if (!currentFocus.hasPrimaryFocus) { currentFocus.unfocus(); } },
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.
.
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?
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.
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()?
i am finding issue in uploading my clima app collage project on github which i created using this repository link
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
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):
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.