Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'dart:async';
- import 'dart:convert' show utf8, json;
- import 'dart:io';
- import 'package:flutter/material.dart';
- import 'package:http/http.dart' as http;
- void main() => runApp(new MaterialApp(home: new MTextInput()));
- class MTextInput extends StatefulWidget {
- @override
- MTextInputState createState() => new MTextInputState();
- }
- Future<Map<String, dynamic>> getInstitutes(HttpClient client) async {
- final String url = "https://kretaglobalmobileapi.ekreta.hu/api/v1/Institute";
- final HttpClientRequest request = await client.getUrl(Uri.parse(url))
- ..headers.add("Accept", "application/json")
- ..headers.add("HOST", "kretaglobalmobileapi.ekreta.hu")
- ..headers.add("apiKey", "7856d350-1fda-45f5-822d-e1a2f3f1acf0")
- ..headers.add("Connection", "keep-alive");
- final HttpClientResponse response = await request.close();
- print(json.decode(await response.join()));
- return json.decode(await response.transform(utf8.decoder).join());
- }
- Future<http.Response> fetchPost() {
- return http.get(
- "https://kretaglobalmobileapi.ekreta.hu/api/v1/Institute",
- // Send authorization headers to your backend
- headers : {"apiKey": "7856d350-1fda-45f5-822d-e1a2f3f1acf0", "Connection": "keep-alive",
- "Accept": "application/json", "HOST": "kretaglobalmobileapi.ekreta.hu"}
- );
- }
- void login() async {
- print((await fetchPost()).body);
- print((await fetchPost()).body.length);
- }
- class MTextInputState extends State<MTextInput> {
- @override
- Widget build(BuildContext context) {
- return new Scaffold(
- appBar: new AppBar(title: new Text("E-napló"),),
- body: new Container(
- child: new Center(
- child: new IconButton(
- icon: new Icon(Icons.add),
- onPressed: login
- ),
- )
- )
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement