5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

FlutterでHTTP通信してみる

Posted at

httpパッケージのインストール

以下を参考に、httpパッケージをインストールします
https://pub.dev/packages/http#-installing-tab-

  • pubspec.ymlのdependencieshttp: ^0.12.0+4を追記
    • ※バージョンは記事執筆当時のもの
dependencies:
  http: ^0.12.0+4
flutter pub get

HTTP通信をしてみる

使い方はREADMEを見ましょう
https://pub.dev/packages/http#-readme-tab-

  • http.dartをインポートします
import 'package:http/http.dart' as http;
  • GETの場合
final String url = 'http://www.test.com';
http.get(url);
  • POSTの場合
final dynamic body = {'test': 'aaa'};
final String url = 'http://www.test.com';
http.post(url, body: body);
5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?