1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-08 13:58:47 +00:00
Files
samples/isolate_example
Taha Tesser 1a26473a50 Replace ButtonBar with OverflowBar (#2072)
This PR replaces `ButtonBar` with `OverflowBar` in preparation of
`ButtonBar` deprecation

related to https://github.com/flutter/flutter/issues/127955


## Pre-launch Checklist

- [x] I read the [Flutter Style Guide] _recently_, and have followed its
advice.
- [x] I signed the [CLA].
- [x] I read the [Contributors Guide].
- [ ] I updated/added relevant documentation (doc comments with `///`).
- [x] All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-devrel
channel on [Discord].

<!-- Links -->
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[CLA]: https://cla.developers.google.com/
[Discord]: https://github.com/flutter/flutter/wiki/Chat
[Contributors Guide]:
https://github.com/flutter/samples/blob/main/CONTRIBUTING.md

---------

Co-authored-by: Brett Morgan <brett.morgan@gmail.com>
2023-10-31 15:05:58 +10:00
..
2023-08-17 06:26:43 +10:00
2023-09-07 22:21:54 +00:00
2023-09-07 22:21:54 +00:00
2023-08-17 06:26:43 +10:00
2023-09-07 22:21:54 +00:00
2023-01-25 09:08:51 +10:00
2023-08-24 11:52:33 -05:00

Isolate Example

A sample application that demonstrate best practices when using isolates.

Goals

  • Display the performance benefits of isolates when using them in the right situation.
  • Show how to use the compute method for straightforward computations.
  • Demonstrate how to initialize and use an isolate.
  • Show the cost of moving data between isolates and provide alternatives.

The important bits

performance_page.dart

Compares running a large computation on the main isolate with running the same calculation on a second isolate. When the main isolate is used, Flutter is unable to render new frames, and the SmoothAnimationWidget's animation freezes.

infinite_process_page.dart

Creates an isolate used to run an infinite loop that sums batches of 100M randomly generated numbers at a time. Users can start, terminate, pause, and resume the isolate, as well as modify how the calculation is performed.

data_transfer_page.dart

Demonstrates how expensive it is to move large amounts of data between isolates and a better alternative to move data. This page creates an isolate that can add up a list of numbers and gives users three options for how to provide it with input:

  • Send values normally using a List
  • Send the values using TransferableTypedData
  • Generate the values on the second isolate, so no copying is necessary

Users can then compare the performance of each approach using the displayed timestamps.

Questions/issues

If you have a general question about any of the techniques you see in the sample, the best places to go are:

If you run into an issue with the sample itself, please file an issue in the main Flutter repo.