Search
 
SCRIPT & CODE EXAMPLE
 

DART

Send Form Data in HTTP POST request in Flutter

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);
}
Comment

How to send post request using http in flutter

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

Future<http.Response> postRequest () async {
  var url ='https://pae.ipportalegre.pt/testes2/wsjson/api/app/ws-authenticate';

  Map data = {
    'apikey': '12345678901234567890'
  }
  //encode Map to JSON
  var body = json.encode(data);

  var response = await http.post(url,
      headers: {"Content-Type": "application/json"},
      body: body
  );
  print("${response.statusCode}");
  print("${response.body}");
  return response;
}
Comment

PREVIOUS NEXT
Code Example
Dart :: what is final and const verabile in flutter 
Dart :: flutter fittedbox 
Dart :: flutter widget for space 
Dart :: drawerheader height flutter 
Dart :: dart filter list 
Dart :: how to convert int/int to float dart 
Dart :: dart function as variable 
Dart :: badge flutter 
Dart :: convert string to list in dart 
Dart :: dart getter 
Dart :: how to add icon in the app bar in flutter 
Dart :: flutter how to create copy button 
Dart :: enum flutter 
Dart :: Flutter get each letter from string 
Dart :: Running Gradle task assembleDebug.... 
Dart :: Flutter dynamic table example 
Dart :: get user country automatically flutter 
Dart :: const vs final flutter 
Dart :: flutter add icon 
Dart :: map in dart 
Dart :: flutter showdialog barrierdismissible 
Dart :: internal shadow flutter 
Dart :: odd even in dart 
Dart :: provider flutter docs 
Dart :: split double value in dart 
Dart :: flutter getx state management 
Dart :: tooltip flutter 
Dart :: flutter navigator get result 
Dart :: <i class="fluigicon fluigicon-map-marker icon-xl"</i 
Dart :: flutter run future builder only 1 time 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =