Skip to content

Commit

Permalink
Fix Dart project configuration for headless Dart runners. (flutter#5461)
Browse files Browse the repository at this point in the history
  • Loading branch information
chinmaygarde authored Jun 4, 2018
1 parent 3d87b27 commit 366d0e3
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "flutter/shell/common/switches.h"
#include "flutter/shell/common/thread_host.h"
#include "flutter/shell/platform/darwin/common/command_line.h"
#include "flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject_Internal.h"
#include "lib/fxl/functional/make_copyable.h"

static std::unique_ptr<shell::PlatformView> CreateHeadlessPlatformView(shell::Shell& shell) {
Expand Down Expand Up @@ -72,10 +73,16 @@ - (void)runWithEntrypoint:(NSString*)entrypoint {
return;
}

FlutterDartProject* project =
[[[FlutterDartProject alloc] initFromDefaultSourceForConfiguration] autorelease];

auto config = project.runConfiguration;

config.SetEntrypoint(entrypoint.UTF8String);

// Override the default run configuration with the specified entrypoint.
_shell->GetTaskRunners().GetUITaskRunner()->PostTask(
fxl::MakeCopyable([engine = _shell->GetEngine(),
config = shell::RunConfiguration::InferFromSettings(settings)]() mutable {
fxl::MakeCopyable([engine = _shell->GetEngine(), config = std::move(config)]() mutable {
if (!engine || !engine->Run(std::move(config))) {
FXL_LOG(ERROR) << "Could not launch engine with configuration.";
}
Expand Down

0 comments on commit 366d0e3

Please sign in to comment.