worker_manager 1.1.0 copy "worker_manager: ^1.1.0" to clipboard
worker_manager: ^1.1.0 copied to clipboard

outdated

Executor allows you to create a queue of tasks for threadpool of isolates

example/lib/main.dart

// Copyright Daniil Surnin. All rights reserved.
// Use of this source code is governed by a Apache license that can be
// found in the LICENSE file.

import 'dart:async';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart';
import 'package:worker_manager/worker_manager.dart';

void main() async {
  await Executor().warmUp();
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      showPerformanceOverlay: true,
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key}) : super(key: key);

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: RaisedButton(
            child: Text('fib(40)'),
            onPressed: () {
              final task =
                  Task<int, int>(function: fib, bundle: 39, timeout: Duration(seconds: 25));
              Executor().addTask<int, int>(task: task).listen((data) {
                print(data);
              }).onError((error) {
                print(error);
              });
            }),
      ),
    );
  }
}

int fib(int n) {
  if (n < 2) {
    return n;
  }
  return fib(n - 2) + fib(n - 1);
}

Future<String> getData(String link) async => (await get(link)).body.toString();
298
likes
0
pub points
94%
popularity

Publisher

verified publisherrenesanse.net

Executor allows you to create a queue of tasks for threadpool of isolates

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

async, flutter

More

Packages that depend on worker_manager