filiph
filiph

Reputation: 3113

How do I run a command line tool that depends on Flutter?

The flutter_test package is able to run Flutter apps 'headless', without requiring any embedder. It would be useful to me to be able to run a command line tool (i.e. not a test) in the same mode. Is this possible? I looked at the flutter_test package but nothing there seems to be the magic solution.

What I've tried:

Upvotes: 2

Views: 711

Answers (1)

Ben Konyi
Ben Konyi

Reputation: 3229

If your code relies on package:flutter or dart:ui, you won't be able to run it outside of a Flutter engine instance (e.g., flutter_tester or a Flutter application) as dart:ui is a custom core library for Flutter that isn't part of Dart's core libraries. Short of hacking away at flutter_tester to remove the test runner related logic or creating your own custom embedder of the Flutter engine, you won't be able to run a Flutter project headless on the command line.

Ideally, you'd just refactor your tool to not depend on dart:ui at all, but given your background I'm guessing you're trying to do something non-standard that actually requires functionality from the Flutter framework... :-)

Upvotes: 6

Related Questions