isohttpd 0.2.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 74

Isohttpd #

pub package

A lightweight http server that runs in an isolate. Powered by Iso

Example #

   import 'dart:io';
   import 'dart:async';
   import 'package:isohttpd/isohttpd.dart';

   Future<HttpResponse> handler(HttpRequest request, IsoLogger log) async {
     return jsonResponse(request, {"response": "ok"});

   void main() async {
     // set routes
     final defaultRoute = IsoRoute(path: "*", handler: handler);
     final routes = <IsoRoute>[defaultRoute];
     final router = IsoRouter(routes);

     // run
     final iso = IsoHttpdRunner(host: "localhost", router: router);
     await true);

     // listen to logs
     iso.logs.listen((String data) => print("$data"));
  iso.requestLogs.listen((ServerRequestLog data) => print("=> $data"));
     // idle
     final waiter = Completer<Null>();
     await waiter.future;

Commands #

Start the server:

   await false);

Stop the server:


Server status:


Utils #

Send a json response from a handler:

   jsonResponse(request, {"response": "ok"});

Decode multipart/form-data:

   final body = await decodeMultipartRequest(request);
   final dynamic data =;

List a directory's content:

   final data = await directoryListing(Directory(somePath));

Changelog #

0.2.0 #

  • Use pedantic for analysis options
  • Use typed data for logs streams
  • Linting

0.1.0 #



Examples #

Command line example:

   Future<HttpResponse> handler(HttpRequest request, IsoLogger log) async {
     request.response.statusCode = HttpStatus.ok;
     return request.response;

   Future<String> initHost() async {
     final interfaces = await NetworkInterface.list(
         includeLoopback: false, type: InternetAddressType.any);
     return interfaces.first.addresses.first.address;

   void main() async {
     // set routes
     IsoRoute onGet = IsoRoute(path: "*", handler: handler);
     List<IsoRoute> routes = <IsoRoute>[onGet];
     final router = IsoRouter(routes);
     // set host
     String host = await initHost();
     // run
     print("Running the server in an isolate");
     IsoHttpdRunner iso = IsoHttpdRunner(host: host, router: router);
     await true);
     // listen to logs
     iso.logs.listen((dynamic data) => print("$data"));
     iso.requestLogs.listen((dynamic data) => print("REQUEST $data"));
     // idle
     while (true) {}

Use this package as a library

1. Depend on it

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

  isohttpd: ^0.2.0

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or 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:isohttpd/isohttpd.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Nov 8, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.6.0
  • pana: 0.12.21


Detected platforms: Flutter, other

Primary library: package:isohttpd/isohttpd.dart with components: io, isolate.

Health issues and suggestions

Document public APIs. (-0.68 points)

92 out of 93 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.

Fix lib/src/utils.dart. (-0.50 points)

Analysis of lib/src/utils.dart reported 1 hint:

line 15 col 11: 'parseBody' is deprecated and shouldn't be used.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.0 <3.0.0
body_parser ^1.1.1 1.1.1
iso ^0.2.2 0.2.3
meta ^1.1.7 1.1.8
pedantic ^1.8.0+1 1.8.0+1
Transitive dependencies
charcode 1.1.2
collection 1.14.12
dart2_constant 1.0.2+dart2
http_parser 3.1.3
http_server 0.9.8+3
mime 0.9.6+3
path 1.6.4
source_span 1.5.5
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
Dev dependencies
test ^1.6.5