Isolate helper for flutter and dart.

Related tags

Templates isolation
Overview

Isolation

platform_info Actions Status Coverage License: MIT Linter


Overview

The package simplifies the creation and interaction between isolates. It encapsulates the entire boilerplate, leaving the developer with only transport with an API that looks like two stream controllers.

The package also helps to preserve typing and pass exceptions between isolates.

Usage

JSON parser

import 'dart:async';
import 'dart:convert' show jsonDecode;

import 'package:isolation/isolation.dart';

typedef JsonMap = Map<String, Object?>;

/// Main isolate
void main() => Future<void>(() async {
      // Create a new isolate controller
      final controller = IsolateController<String, JsonMap>(
        _parser,    // Isolate function
        lazy: true, // The isolate will not be created until the first message
      )
       // Add few messages to the isolate:
       ..add('{}')
       ..add('{"field": 123}')
       ..add('{"fizz": "buzz", "value": 2, "undefined": null}');
      // Listen messages from slave isolate
      await controller.stream.take(3).forEach(print);
      // Gracefully closing connection and finally kill slave isolate
      await controller.close(force: false);
    });

/// Slave isolate for parsing JSON, where you can subscribe to the stream
/// from the main isolate and send the result back through the controller.
Future<void> _parser(IsolateController<JsonMap, String> controller) =>
    controller.stream.forEach((json) {
      final result = jsonDecode(json) as Object?;
      (result is JsonMap)
          ? controller.add(result)
          : controller.addError(const FormatException('Invalid JSON'));
    });

Installation

Add the following to your pubspec.yaml file to be able to do code generation:

dependencies:
  isolation: any

Then run:

dart pub get

or

flutter pub get

Coverage

Changelog

Refer to the Changelog to get all release notes.

Maintainers

Plague Fox

License

MIT

You might also like...

Notes is a good helper to manage your schedules and notes

Notes is a good helper to manage your schedules and notes. It gives you a quick and simple notepad editing experience when you write notes, memo, email, message, shopping list and to do list. It makes to take a note easier than any other notepad and memo apps.

Nov 16, 2022

A sign in button helper library for Flutter

A sign in button helper library for Flutter

A Flutter plugin for iOS and Android for generating signin buttons for different social media account. Feedback and Pull Requests are most welcome! In

Dec 29, 2022

Helper pub package for flutter_icons

flutter_icons_helper An helper implementing utility methods for package flutter_

Jun 22, 2022

Helper for building advanced multi child layouts.

Helper for building advanced multi child layouts.

About Boxy is designed to overcome the limitations of Flutter's built-in layout widgets, it provides utilities for flex, custom multi-child layouts, d

Dec 12, 2022

Helper app to run code on Aliucord iOS via websocket.

aliucordebug A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if

Jan 25, 2022

The Integration Test Helper has pre-configured methods that allow for faster test deployment for end to end (e2e) test coverage.

The Integration Test Helper has pre-configured methods that allow for faster test deployment for end to end (e2e) test coverage.

The Integration Test Helper has pre-configured methods that allow for faster test deployment for end to end (e2e) test coverage (using Android and iOS

Apr 7, 2022

Mysql.dart - MySQL client for Dart written in Dart

Native MySQL client written in Dart for Dart See example directory for examples

Dec 29, 2022

Flutter Navigation - all types of navigation in flutter run main.tabBar.dart to see tabBar, and run main.dart to see the otheres

pop_up_bar A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if th

Jan 1, 2022

Flutter Dart-Projesi - Meditation app developed using Flutter and Dart

Flutter Dart-Projesi - Meditation app developed using Flutter and Dart

Müzik Çalar Meditasyon Uygulaması Medi Flutter ve Dart ile programlanmış bir med

Jan 29, 2022
Owner
Plague Fox
Talks about @dart-lang and @flutter
Plague Fox
Dart package that conveniently wraps an isolate, ports and state for easy isolates.

Isolate Agents Description Isolate Agents adds a new class, Agent, which is a proper implementation of the Actor model for Dart. Where Isolates have n

null 65 Jan 2, 2023
An isolated worker for Flutter (Isolate) and Web (Web Worker). Behaves almost the same as the compute function, except it is not a one-off worker.

A singleton isolated worker for all platforms. On most platforms, it uses Flutter's Isolate, except on the web, since Isolate is not available, it use

Iandi Santulus 30 Nov 11, 2022
Learn how to build a multi-step form flow and how to use bloc to effectively isolate the presentation layer from the business logic layer.

Multi-page Form Flow Learn how to build a multi-step form flow and how to use bloc to effectively isolate the presentation layer from the business log

Sandip Pramanik 15 Dec 19, 2022
A Flutter package which allows you to work with MethodChannels in Isolate.

A Flutter package which allows you to work with MethodChannels in Isolate. Also it provides simplified multiplatform Isolate API.

Zemlaynikin Max 19 Jan 4, 2023
Aplicativo de teste que roda em background timer atual utilizando Isolate.

# isolate_app A new Flutter project. ## Getting Started This project is a starting point for a Flutter application. A few resources to get you sta

Isaque Santos Paixão 1 Jun 20, 2022
This a library to simplify isolate thread communication.

This a library to simplify islate thread communication. It abstracts the data transfer between islate and the main thread into a simple channel, and t

吴楚衡 3 Oct 31, 2022
A dart package for many helper methods fitting common situations

Basic Utils A dart package for many helper methods fitting different situations. Table of Contents Basic Utils Table of Contents Preamble Install pubs

null 275 Jan 5, 2023
:bug: Flutter debug helper widget with common and custom actions

Debug Friend Flutter debug helper widget with common and custom actions This helps you reduce the development and testing time of new features Show so

Stanislav Ilin 43 Dec 7, 2022
Zooper flutter encoding utf16 - Helper classes to encode and decode UTF16 string to List

zooper_flutter_encoding_utf16 Helper classes to encode and decode UTF16 string t

Zooper 0 Feb 10, 2022
Nebula makes your Flutter development journey easier by providing helper widgets, utilities and abstractions.

Nebula makes your Flutter development journey easier by providing helper widgets, utilities and abstractions.

Aldrin's Art Factory 1 Apr 21, 2022