flutter_persistent_queue 0.0.1 copy "flutter_persistent_queue: ^0.0.1" to clipboard
flutter_persistent_queue: ^0.0.1 copied to clipboard

outdated

Simple file-based non-volatile queue for flutter. Ideal for in-device sequential buffers that persist between app runs.

example/lib/main.dart

// ignore_for_file: strong_mode_implicit_dynamic_type

import 'dart:math';
import 'package:collection/collection.dart';
import 'package:flutter/material.dart';
import 'package:flutter_persistent_queue/flutter_persistent_queue.dart';

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

Future<void> _assert() async {
  print('assertions started');

  print('queue instantiated');
  final pq = PersistentQueue(filename: 'pq', flushAt: 100000);
  await pq.setup();
  print('queue setup');

  await pq.flush();
  print('queue ready');

  final Set<int> source = Set(), target = Set();
  for (int i = 1000; i > 0; --i) {
    final int val = Random().nextInt(4294967296);
    source.add(val);
    await pq.push(<String, dynamic>{'val': val});
  }
  print('queue loaded');

  await pq.flush((list) async {
    target.addAll(list.map((val) => val['val'] as int));
  });
  print('queue cleared');

  final sourceList = source.toList(), targetList = target.toList();
  sourceList.sort();
  targetList.sort();
  assert(IterableEquality().equals(sourceList, targetList));

  print('queue assertion finished');
}

class _MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    _assert();
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: Text('Please check the debug console'),
        ),
      ),
    );
  }
}
10
likes
0
pub points
17%
popularity

Publisher

unverified uploader

Simple file-based non-volatile queue for flutter. Ideal for in-device sequential buffers that persist between app runs.

Homepage
Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

collection, flutter, localstorage, meta, synchronized

More

Packages that depend on flutter_persistent_queue