flutter

dart lang cheatsheet

paulaner80 2019. 10. 29. 12:30
반응형

List

List<String>

 

map

void main() {
  List<String> bb = ["a", "b", "c", "d", "e"];
  
  List<String>  cc = bb.map((s){
    return s +"BB";
  }).toList();
  
  print(cc);
}
 

 

 

http

import 'package:http/http.dart' as http;
import 'dart:convert';

void main(List<String> args) async {
  var client = http.Client(); 
  try { 
    final response = await client.get(Uri.parse('url 주소'));

    if(response.statusCode == 200){
      print(response.body); //한글깨질 수 있음.
      print(utf8.decode(response.bodyBytes)); //한글깨짐문재 해결
    }
  } 
  finally { 
    client.close(); 
  }
}