flutter post 帶參數寫法

import 'package:flutter/material.dart';
import 'scenery/snacks.dart';
import 'dart:io';
import 'dart:convert';

void main() async {

  HttpClient client = new HttpClient();
  var request = await client.postUrl(Uri.parse("http://192.168.199.1/phone/000002"));
  
  request.headers.add("Content-Type","application/x-www-form-urlencoded");
  request.write("category=mouse");
  
  var response = await request.close();
  var data = await response.transform(utf8.decoder).single;
  print('Response ${response.statusCode}: $data');
  var gameServerConfig = jsonDecode(data);

  print(gameServerConfig);
相關文章
相關標籤/搜索