native_http 1.0.1+1

  • Readme
  • Changelog
  • Example
  • Installing
  • 74

native_http #

A package that calls network from native platform ie OkHttp on Android and URLSession iOS.

Getting Started #

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

  Future<void> runCalls() async {
    native_http.NativeResponse respGet =
        await native_http.get("http://example.com/get");
    print(respGet.body);
    native_http.NativeResponse respPost = await native_http.post(
      "http://example.com/get",
      body: {"username": "username", "password": "password"},
    );
    print(respPost.body);
  }

1.0.1+1 #

  • Added json getter to get parsed json data

1.0.0+5 #

  • Empty header issue handled

1.0.0+4 #

  • Handled no network call crash issue

1.0.0+3 #

  • Fixed bug on iOS

1.0.0+2 #

  • Added header for api calls added

1.0.0+1 #

  • Added example

1.0.0 #

  • Works on both android and iOS

0.0.3 #

  • Introduced request method

0.0.2 #

  • Works on android

0.0.1 #

  • Initial release.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';

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

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
    runCalls();
  }

  Future<void> runCalls() async {
    native_http.NativeResponse respGet = await native_http
        .get("https://5eb4371f2b81f70016308301.mockapi.io/api/users");
    native_http.NativeResponse respPost = await native_http.post(
      "http://newweb.nepalstock.com.np/api/authenticate/login",
      headers: {
        "Origin": "http://newweb.nepalstock.com.np",
        "Host": "http://newweb.nepalstock.com.np",
      },
      body: {"username": "username", "password": "password"},
    );
    print(respPost.body);
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: RaisedButton(
            child: Text('Run an http call'),
            onPressed: runCalls,
          ),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  native_http: ^1.0.1+1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:native_http/native_http.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
56
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
74
Learn more about scoring.

We analyzed this package on Jul 2, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because of import path [package:native_http/native_http.dart] that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because of import path [package:native_http/native_http.dart] that declares support for platforms: android, ios

Package does not support Flutter platform web

Because of import path [package:native_http/native_http.dart] that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because of import path [package:native_http/native_http.dart] that declares support for platforms: android, ios

Package not compatible with SDK dart

because of import path [native_http] that is in a package requiring null.

Health issues and suggestions

Document public APIs. (-1 points)

11 out of 11 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Maintenance issues and suggestions

Use constrained dependencies. (-20 points)

The pubspec.yaml contains 1 dependency without version constraints. Specify version ranges for the following dependencies: http.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
http any 0.12.1
Transitive dependencies
charcode 1.1.3
collection 1.14.12 1.14.13
http_parser 3.1.4
meta 1.1.8
path 1.7.0
pedantic 1.9.0 1.9.1
sky_engine 0.0.99
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
flutter_test