request_api_helper 3.0.0+8 copy "request_api_helper: ^3.0.0+8" to clipboard
request_api_helper: ^3.0.0+8 copied to clipboard

outdated

http, shared_preferences helper for Lavarel and other.

Request Api Helper #

Post, Get, Save, Helper for Flutter;

Installation #

Add this to your package's pubspec.yaml file:

dependencies:
  request_api_helper:

Usage #

import 'package:request_api_helper/request.dart' as req;

1 . Setting Config #

use static Env in main like this (Release):

import 'package:request_api_helper/model/config_model.dart';

void main(
  RequestApiHelperConfig.save(
    RequestApiHelperConfigData(
      url: 'https://official-joke-api.appspot.com/',
      noapiurl: 'https://official-joke-api.appspot.com/',
      logResponse: true,
      withLoading: Redirects(toogle: false),
    ),
  );
  runApp(MyApp());
}

2 . Make Login And Saving Token #

First you must make login request.

login() async {
======================= GET DATA FROM SERVER
  await req.send(
    name: 'login',
    type: RESTAPI.POST,
    data: RequestData(
      body: {
        'username' : username,
        'password' : password,
      }
    ),
    RequestApiHelperConfigData(
      onSuccess: (response) async {
        // important
        await Session.save('token', 'Bearer ' + response['token']);

        // auto save different type data
        await Session.save('user_name', response['user']['name']);
        await Session.save('user_id', response['user']['id']);
      },
    ),
  );
}

3 . What is Session? #

session is Shared preferences plugin, implement :

save to Shared Preferences

await Session.save('myname','MIAUW'); // String
await Session.save('myint',100); // int
await Session.save('mybool',false); // bool

load from Shared Preferences

String mystring = await Session.load('myname'); // String
int myint = await Session.load('myint'); // int
bool mybool = await Session.load('mybool'); // bool

6
likes
0
pub points
29%
popularity

Publisher

unverified uploader

http, shared_preferences helper for Lavarel and other.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, fluttertoast, http, http_parser, shared_preferences

More

Packages that depend on request_api_helper