Skip to content

Commit

Permalink
add http.get
Browse files Browse the repository at this point in the history
  • Loading branch information
hiroyuki12 committed Feb 15, 2020
1 parent 1b92872 commit 3e1c1e0
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion lib/main.dart
@@ -1,4 +1,5 @@
import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;

void main() => runApp(MyApp());

Expand Down Expand Up @@ -26,13 +27,27 @@ class MyHomePage extends StatefulWidget {
}

class _MyHomePageState extends State<MyHomePage> {
String _data = '';

@override
void initState() {
super.initState();
_load();
}

Future<void> _load() async {
final res = await http.get('https://api.github.com/repositories/31792824/issues');
setState(() {
_data = res.body;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Text('空っぽの画面です'),
body: Text(_data),
);
}
}

0 comments on commit 3e1c1e0

Please sign in to comment.