Coder Social home page Coder Social logo

hamas-ur-rehman / httpservice Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 108 KB

This package contains classes that make it easy to consume the http package. It's multi-platform, and supports mobile, desktop, and the browser. It supports GET,PUT,POST,DELETE and PATCH requests. It Depends on the http package

License: MIT License

Kotlin 0.33% Swift 1.06% Objective-C 0.10% Dart 12.44% HTML 9.73% CMake 20.97% C++ 53.48% C 1.88%
flutter http http-server serverrequestinterface classes dart dart-library flutterpackage hacktoberfest

httpservice's Introduction

httpservice

A FLutter package that depends on http package.

Getting Started

This package contains classes that make it easy to consume the http package. It's multi-platform, and supports mobile, desktop, and the browser. It supports GET,PUT,POST,DELETE and PATCH requests

Using

The easiest way to use this library is to initialize the class and call the function:

import 'dart:convert';
import 'package:httpservice/httpservice.dart';

void getapidata(String apix) async {
    HttpService httpService = HttpService("$apix");
    var data = await httpService.getContents();
    var decodedData = jsonDecode(data);
    print(decodedData);
  }

GET

import 'dart:convert';
import 'package:httpservice/httpservice.dart';

void getapidata(String apix) async {
    HttpService httpService = HttpService("$apix");
    var data = await httpService.getContents();
    var decodedData = jsonDecode(data);
    print(decodedData);
  }

POST

import 'dart:convert';
import 'package:httpservice/httpservice.dart';

void postapidata(String apix) async {
    HttpService httpService = HttpService("$apix");
    var data = await httpService.postContents(headers: {"Content-type": "application/json"},body: '{"title": "Hello", "body": "body text", "userId": 1}');
  }

PUT

import 'dart:convert';
import 'package:httpservice/httpservice.dart';

void postapidata(String apix) async {
    HttpService httpService = HttpService("$apix");
    var data = await httpService.putContents(headers: {"Content-type": "application/json"},body:'{"title": "Hello", "body": "body text", "userId": 1}');
  }

PATCH

import 'dart:convert';
import 'package:httpservice/httpservice.dart';

void postapidata(String apix) async {
    HttpService httpService = HttpService("$apix");
    var data = await httpService.putContents(headers: {"Content-type": "application/json"},body:'{"title": "Hello"}');
  }

DELETE

import 'dart:convert';
import 'package:httpservice/httpservice.dart';

void postapidata(String apix) async {
    HttpService httpService = HttpService("$apix");
    var data = await httpService.deleteContents();
  }

httpservice's People

Contributors

hamas-ur-rehman avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.