Application types - flutter-tizen/flutter-tizen GitHub Wiki

You can create three different types of app projects using the flutter-tizen create command.

UI app

This is the default type of application suited for most Flutter applications.

To create a UI app project, use the flutter-tizen create command without specifying --app-type.

flutter-tizen create app_name

Service app

Service apps are applications that run in the background and do not have a graphical user interface. They can be useful for performing activities that need to run periodically or continuously, but do not require any user intervention (such as retrieving sensor data).

To create a service app project, use the flutter-tizen create command with the --app-type service option.

flutter-tizen create --app-type service app_name

The created project comes with sample code in lib/main.dart that looks like:

import 'package:flutter/widgets.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();

  int counter = 0;
  while (true) {
    print('Counter: ${counter++}');
    await Future.delayed(const Duration(seconds: 1));
  }
}

Please make sure to call WidgetsFlutterBinding.ensureInitialized() at the beginning of the main function to allow your app to access platform channels.

A service app is not launched automatically and must be explicitly launched by a UI app. It is also not automatically restarted when it is terminated or when the device is restarted.

Since service apps do not provide a user interface to interact with, the most effective way to exchange commands and messages with other apps is to use the messageport_tizen plugin.

Multi-project app

A multi-project app is an application that has both UI and service apps in one TPK package. It allows both parts of the apps to access their internal shared resources. The UI part can handle user interactions, and the service part can perform operations that can run in the background.

To create a multi-project app, use the flutter-tizen create command with the --app-type multi option.

flutter-tizen create --app-type multi app_name

The created project comes with sample code in lib/main.dart that looks like:

// This function is the entry point for the UI app.
void main() {
  runApp(const MyApp());
}

// This function is the entry point for the service app.
@pragma('vm:entry-point')
void serviceMain() {
  ...
}

A service app is not launched automatically and must be explicitly launched by a UI app. The lib/main.dart sample code provides a basic example of launching and stopping a service app from a UI app. The app developer should define at which point of the app lifecycle the service app should be launched and stopped.

Although the UI and service apps share the same source file, they run as separate processes and do not share memory (no global variable can be used). The most effective way to exchange commands and messages between the two apps is to use the messageport_tizen plugin.

⚠️ **GitHub.com Fallback** ⚠️