isolates_helper 0.2.1 copy "isolates_helper: ^0.2.1" to clipboard
isolates_helper: ^0.2.1 copied to clipboard

unlisted

An easy way to create multiple long live isolates for computation, support try-catch block.

example/lib/main.dart

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

@pragma('vm:entry-point')
int add(dynamic values) => values[0] + values[1];

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String text = '';
  final isolates = IsolatesHelper(concurrent: 3, isDebug: true);

  @override
  void initState() {
    super.initState();
  }

  void calculate() {
    isolates(add, [3, 4]).then((value) {
      setState(() => text = '$value');
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
            child: Column(
          children: [
            Text('Result: $text'),
            ElevatedButton(onPressed: calculate, child: const Text('Calculate'))
          ],
        )),
      ),
    );
  }
}
7
likes
0
pub points
61%
popularity

Publisher

verified publisherlamnhan.dev

An easy way to create multiple long live isolates for computation, support try-catch block.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

isolate_manager

More

Packages that depend on isolates_helper