API for Login and Signup

Dear Techie,
I m new to flutter technology, Currently I’m creating one flutter base app for customer.
Front End - Flutter (Dart)
Back End - Sql Server (Microsoft)

Actually i struck with functionality Login with API . I m having Login api but i dont know how to fetch the access token .
Can you guys help me out ?

Here is one method which provide authentication.

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

String pass='123456789'
String email='mrmodh10@gmail.com'

authenticate(String email, String pass) async {
    String myurl =
        "here pass your url";
    http.post(myurl, headers: {
      'Accept': 'application/json',
      'authorization': 'pass your key(optional)'
    }, body: {
      "email": email,
      "password": pass
    }).then((response) {


In that response you will get access token.

Heyy @Vasanth_kumar ! As you can see above, he has portrayed an HTTP request using the http package. You can hit your login API in a similar manner.

You should first test your API using Postman and check if its working properly, your response.body should contain something like this:

   api_token: "<API_TOKEN>",
   message: "Logged in successfully!",
   success: true

You can then get the API token like this:


Hope this helps :slight_smile:

hello Vasanth_kumar,
I am a university student. I have questions about flutter and sql server.
please,can you contact me.
my email adress:

this is almost same as @AddWebSolution but this is my version

signInMethod(String email, String password) async {

String url = "https://yourLoginApiUrl";
var response = await http.post(url, body: {
  "email": email,
  "password": password

  var jsonResponse = null;

  if (response.statusCode == 200) {
    jsonResponse = json.decode(response.body);
    if (jsonResponse != null) {

      *print(jsonResponse['token']);*  // for Printing the token

      // Navigator used to enter inside app if the authentication is correct
            builder: (BuildContext context) => HomePage(),
          (Route<dynamic> route) => false);
  } else {
    print("Error message like email or password wrong!!!!");  // Toast

This is worked for me
Happy Coding … :innocent: