go_online

Last updated:

0 purchases

go_online Image
go_online Images
Add to Cart

Description:

go online

This package provides a GoOnline class that can be used to make HTTP requests to a RESTful API. The class is designed to simplify the process of sending HTTP requests by abstracting away the implementation details of the http package.
The GoOnline class has methods for sending GET, POST, PUT, and DELETE requests to an API.
Features #
This package can be used to send HTTP requests to a RESTful API. Specifically, it provides methods for sending GET, POST, PUT, and DELETE requests to an API, along with the necessary headers for each request.
It also includes a method for retrieving an authentication token from the device's SharedPreferences.
The GoOnline class can be instantiated with a base URL for the API, and the postData(), getData(), updateData(), and deleteData() methods can be used to send requests to the API with the provided data. The responses from the API can be handled using the http package's built-in response handling functions.
Getting started #
import the package
Usage #
import 'package:flutter/material.dart';
import 'package:go_online/go_online.dart';

class MyWidget extends StatelessWidget {
final api = GoOnline();

@override
Widget build(BuildContext context) {
return ElevatedButton(
onPressed: () async {
//Your BaseURL
String baseURL='https://www.example.com';
goOnline.baseurl=baseURL;
final data = {'name': 'John', 'email': '[email protected]'};
//Using the POST method
final response = await api.postData(data, '/users');
print(response.body);
},
child: Text('Send Request'),
);
}
}
copied to clipboard
var goOnline = GoOnline();
//Your BaseURL
String baseURL='https://www.google.com';
goOnline.baseurl=baseURL;
var tokenKey='yourTokenFromSharedPreference';
goOnline.token=tokenKey;

//Using the Get method
var fetch = await goOnline.getData('/search?q=Rarible');
print(fetch.body);
var data = {'name': 'John', 'email': '[email protected]'};
var response = await goOnline.postData(data, 'users');
var fetch = await goOnline.getData('demo.com/api');
print(fetch.body);

print(response.body);


var responseUpdate = await goOnline.updateData(data, 'users/1');
print(responseUpdate.body);

var responseDelete = await goOnline.deleteData('users/1');
print(responseDelete.body);
copied to clipboard
Additional information #
Visit Flutter.dev

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.