Send Form Data in HTTP POST request in Flutter

188

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

void main() {
    // This will be sent as form data in the post requst
    var map = new Map<String, dynamic>();
    map['username'] = 'username';
    map['password'] = 'password';

    final response = await http.post(
        Uri.parse('http/url/of/your/api'),
        body: map,
    );

    print(response.body);
}

Comments

Submit
0 Comments