Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lesson 26 get does not take url as link #42

Open
mhrshuvo opened this issue May 23, 2021 · 0 comments
Open

Lesson 26 get does not take url as link #42

mhrshuvo opened this issue May 23, 2021 · 0 comments

Comments

@mhrshuvo
Copy link

mhrshuvo commented May 23, 2021

` import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;
import 'dart:convert';

class Loadding extends StatefulWidget {
@OverRide
_LoaddingState createState() => _LoaddingState();
}

class _LoaddingState extends State {
void getTime() async {

http.Response response = await http.get(Uri.parse('https://jsonplaceholder.typicode.com/todos/1'));
Map data = jsonDecode(response.body);
print(data);
print(data['title']);

}

@OverRide
void initState() {
super.initState();
getTime();
}

@OverRide
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("loading"),
centerTitle: true,
),
body: Row(
children: [
ElevatedButton.icon(onPressed: (){
Navigator.pushNamed(context, '/home');
}, icon: Icon(Icons.home), label: Text('Home'))
],
),
);
}

}
`

this will work fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant