728x90
반응형
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
http: ^1.1.2
import
import 'package:http/http.dart' as http;
함수
void _request() async {
try {
final url = Uri.parse('https://example.com/test);
http.Response response = await http.get(url);
print('_request.. response:$response');
print('_request.. response:${response.body}');
if (response.statusCode == 200) {
final data =jsonDecode(response.body); // dynamic type
print('data... $data');
}
} catch (e) {
throw Exception('_request error');
}
}
728x90
반응형
'dev > flutter' 카테고리의 다른 글
[Flutter] 기존 프로젝트에 플랫폼(Platform) 추가(add)하기 (0) | 2023.12.29 |
---|---|
[Flutter] Native Plugin플러그인 정리(AOS) (0) | 2023.12.28 |
[Flutter] 네이티브(NativeView) 안드로이드(AOS)연동 액티비티(Activity)통신 (0) | 2023.12.27 |
[Flutter] Navigation 네비게이션 정리 (0) | 2023.12.19 |
[Flutter] 기본 위젯2 정리 (0) | 2023.12.19 |