Skip to content

Add support for custom Dart entrypoints #171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 26, 2021

Conversation

swift-kim
Copy link
Member

@swift-kim swift-kim commented Jul 22, 2021

Usage:

In main.dart,

void main() {
  // I'm not a real main!
}

@pragma('vm:entry-point')
void anotherMain() {
  runApp(MyApp());
}

In runner.cc (native app),

bool OnCreate() {
  dart_entrypoint_ = "anotherMain";
  ...

or in App.cs (.NET app),

protected override void OnCreate()
{
    DartEntrypoint = "anotherMain";
    ...

Caveats:

  • The app's main Dart file must declare main() even if it's unused. It's a requirement by the Dart compiler but not the flutter-tizen tool.
  • The use of custom entrypoints may break app builds if the app depends on one or more FFI-based plugins. This is supposed to be a very rare scenario.

Depends on flutter-tizen/engine#152.

Closes flutter-tizen/engine#111.

@swift-kim swift-kim added the no merge This PR is not ready for merge yet label Jul 22, 2021
@swift-kim
Copy link
Member Author

Public methods such as SetEntrypoint() may be added later. The current support is experimental.

@swift-kim swift-kim removed the no merge This PR is not ready for merge yet label Jul 23, 2021
@swift-kim swift-kim requested a review from a team July 23, 2021 06:52
Copy link
Contributor

@bbrto21 bbrto21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this using .Net host and it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support dart entrypoint
2 participants