Skip to content

Instantly share code, notes, and snippets.

@hongsw
Created October 31, 2022 10:21
Show Gist options
  • Save hongsw/efe6f74a56a72950485fdc1e2e93fb16 to your computer and use it in GitHub Desktop.
Save hongsw/efe6f74a56a72950485fdc1e2e93fb16 to your computer and use it in GitHub Desktop.
3.3-변수이용하여 화면구성 http.get

3.3-변수이용하여 화면구성 http.get

Created with <3 with dartpad.dev.

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