jsonstreamreader 1.1.9 copy "jsonstreamreader: ^1.1.9" to clipboard
jsonstreamreader: ^1.1.9 copied to clipboard

This project processes local and remote json files/sources by splitting it into smaller chunks, with automatic garbage collecting.

example/main.dart

import 'package:jsonstreamreader/jsonstreamreader.dart';
import 'dart:async';

void main() {
  RemoteSource f =
      new RemoteSource('https://jsonplaceholder.typicode.com/posts');
  f.setBody({'userId': '1'});
  Streamer s = new Streamer(f, chunksize: 100);
  //Not Ready to start reading so I use hault
  Reader r = new Reader(s, combine: 1)..hault();
  //StreamReader r = new StreamReader(s, combine: 1)..hault();
  r.trailing((dynamic value, String key) {
    print("key is ${key} and value is ${value}");
  });

  ///r.trailing.listen((StreamItem item) {
  ///  print("key is ${item.key} and value is ${item.value}");
  ///});
  r.progress((p) {
    print(p);
  }).done(() {
    print('Completed');
  }).fail((error) {
    print(error);
  });

  ///r.progress.listen((double p) {
  ///  print("completed ${p}%");
  ///});
  ///r.done.listen((_) {
  ///  print("completed");
  ///});
  ///r.error.listen((error) {
  ///  print(error);
  ///});
  new Timer(new Duration(seconds: 1), () {
    //start reading
    r.begin();
  });
  FileState.notinuse.listen((d) {
    print('this file is free to delete');
    print(d);
  });
  r.onpause((ReaderState state) {
    print(state.toString());
  });

  ///Pause the reader
  new Timer(new Duration(seconds: 3), () {
    r.pause().then((ReaderState state) {
      //here you code store state.toString() in a file or just resume
      new Timer(new Duration(seconds: 3), () {
        r.resume();
      });
    });
  });
  f.downloaded.listen((onData) {
    //File will always be download before parsing is done
    //but parsing is started as soon as data is available,i.e while the file is downloading
    print('File has been downloaded');
  });
  f.download();
}
0
likes
35
pub points
0%
popularity

Publisher

unverified uploader

This project processes local and remote json files/sources by splitting it into smaller chunks, with automatic garbage collecting.

Homepage

License

MIT (LICENSE)

Dependencies

flutter, heavylist, path, path_provider

More

Packages that depend on jsonstreamreader