Search code examples
flutterperformancedartimage-processingflutter-canvas

Dart: Get bytes from Flutter-Canvas without opening Flutter App


Background

I am developing a pure Dart command line tool, which combines images from files.

Think creating NFTs by stacking images.

Using the pure Dart image library is slow, it takes about 11-20 seconds for one image sized 3000 x 3000.

Tried

Adding Flutter and using Flutter-Canvas to increase performance does not allow me to compile a Dart command line EXE.

I tried flutter build windows but the result always does open a window / head. And it does not work, just sits there.

Questions regarding possible solutions

  1. Is there a way to combine images more efficently than image?

  2. Is there a way to create a Dart command line EXE which uses Flutter-Canvas as a library?

  3. Flutter Tests run headless; is there a way to imitate that behaviour und thus run Flutter-Canvas headless?


Solution

  • Flutter Tests

    One approach would be to hijack Flutter Tests, but these cannot be turned into a redistributable app or command:

    https://andrewzuo.com/headless-flutter-apps-39168d20277b

    https://andrewzuo.com/passing-arguments-to-headless-flutter-apps-773435c6eae6

    Command Line Package

    A different apporach would be to use this package, which modifies code in the ./windows folder:

    This plugin allows you to run a flutter windows app in gui, or commandline mode. io.dart is used to access stdout and stderr

    https://pub.dev/packages/commandline_or_gui_windows