Created with <3 with dartpad.dev.
Created
October 31, 2022 10:21
-
-
Save hongsw/efe6f74a56a72950485fdc1e2e93fb16 to your computer and use it in GitHub Desktop.
3.3-변수이용하여 화면구성 http.get
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:convert'; | |
import 'package:http/http.dart'; | |
import 'package:flutter/material.dart'; | |
void main() async { | |
const jsonUrl = "hongsw/67e0d72dffa2908e1715dc89a7b0e802/raw/9c5b1388bd52396ff1917b6928f3bda5fcd3b5c7/webtoon.json"; | |
var toons = []; | |
try{ | |
var response = await get(Uri.https("gist.githubusercontent.com", jsonUrl)); | |
toons = json.decode(response.body)['webtoon']; | |
}catch(e){ | |
print(e); | |
} | |
runApp(MaterialApp( | |
home: Scaffold( | |
appBar: AppBar(title: const Text("내폰내툰")), | |
body: Row( | |
children: toons | |
.map( | |
(item) => Column(children: [ | |
Image.network(item['image']!), | |
Text(item['title']!) | |
]), | |
).toList() | |
)))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment