パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v0.5.1

launch_at_startup

このプラグインにより、Flutter デスクトップアプリが起動時/ログイン時に自動的に起動できるようになります。

macOSWindowsLinux
30日間ダウンロード
4.7万
いいね数
151
Pub ポイント
125

パッケージをインストール

flutter pub add launch_at_startup

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

launch_at_startup パッケージは、macOS、Windows、Linux でユーザーがログインする際に Flutter デスクトップアプリケーションを自動起動できるようにします。このパッケージは、複数のプラットフォーム間で自動起動の動作を確認、有効化、無効化するための簡単な API を提供します。システムモニターや通知ツール、生産性ユーティリティなど、バックグラウンドで継続的に実行される必要があるアプリに特に役立ちます。このプラグインは Flutter のデスクトップサポートとシームレスに統合されており、ネイティブコードの変更は不要です。プラットフォーム固有のメカニズムを利用して、起動エントリを信頼性高く管理します。

用途

  • バックグラウンドモニタリングアプリ
  • システムユーティリティツール
  • 通知サービス
  • 生産性アプリの自動起動
  • 永続的なデスクトップアプリケーション

主な機能

  • クロスプラットフォーム起動制御
  • シンプルな有効/無効化 API
  • プラットフォーム固有の実装
  • ネイティブコードは不要です
  • macOS、Windows、Linux をサポートしています

適している対象

  • 自動起動が必要なデスクトップアプリ
  • システムレベルのユーティリティ
  • 恒常的な存在を必要とするアプリ
  • 複数のデスクトップOSをターゲットにする開発者
  • 手動でのユーザー介入なしで実行されるツール

注意事項

  • 一部のシステムではユーザーの許可が必要です
  • 他の自動起動アプリと競合する可能性があります
  • 動作はOSによってわずかに異なります
  • モバイルアプリには適していません
  • ユーザーはシステム設定で手動で有効にする必要がある場合があります

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

🚀 Ship Your App Faster: Try Fastforge - The simplest way to build, package and distribute your Flutter apps.

launch_at_startup

pub version

This plugin allows Flutter desktop apps to Auto launch on startup / login.


English | 简体中文


Platform Support

Linux macOS* Windows
✔️ ✔️ ✔️

*Required macOS support installation instructions below

Quick Start

Installation

Add this to your package's pubspec.yaml file:

dependencies:
  launch_at_startup: ^0.5.1

Or

dependencies:
  launch_at_startup:
    git:
      url: https://github.com/leanflutter/launch_at_startup.git
      ref: main
Usage
import 'dart:io';

import 'package:launch_at_startup/launch_at_startup.dart';
import 'package:package_info_plus/package_info_plus.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  PackageInfo packageInfo = await PackageInfo.fromPlatform();

  launchAtStartup.setup(
    appName: packageInfo.appName,
    appPath: Platform.resolvedExecutable,
    // Set packageName parameter to support MSIX.
    packageName: 'dev.leanflutter.examples.launchatstartupexample',
  );

  await launchAtStartup.enable();
  await launchAtStartup.disable();
  bool isEnabled = await launchAtStartup.isEnabled();

  runApp(const MyApp());
}

// ...

Please see the example app of this plugin for a full example.

macOS Support

Setup

Add platform channel code to your macos/Runner/MainFlutterWindow.swift file.

import Cocoa
import FlutterMacOS
// Add the LaunchAtLogin module
import LaunchAtLogin
//

class MainFlutterWindow: NSWindow {
  override func awakeFromNib() {
    let flutterViewController = FlutterViewController.init()
    let windowFrame = self.frame
    self.contentViewController = flutterViewController
    self.setFrame(windowFrame, display: true)

    // Add FlutterMethodChannel platform code
    FlutterMethodChannel(
      name: "launch_at_startup", binaryMessenger: flutterViewController.engine.binaryMessenger
    )
    .setMethodCallHandler { (_ call: FlutterMethodCall, result: @escaping FlutterResult) in
      switch call.method {
      case "launchAtStartupIsEnabled":
        result(LaunchAtLogin.isEnabled)
      case "launchAtStartupSetEnabled":
        if let arguments = call.arguments as? [String: Any] {
          LaunchAtLogin.isEnabled = arguments["setEnabledValue"] as! Bool
        }
        result(nil)
      default:
        result(FlutterMethodNotImplemented)
      }
    }
    //

    RegisterGeneratedPlugins(registry: flutterViewController)

    super.awakeFromNib()
  }
}

then open your macos/ folder in Xcode and do the following:

Instructions referenced from "LaunchAtLogin" package repository. Read for more details and FAQ's.

Requirements

macOS 10.13+

Install

Add https://github.com/sindresorhus/LaunchAtLogin in the “Swift Package Manager” tab in Xcode.

Usage

Skip this step if your app targets macOS 13 or later.

Add a new “Run Script Phase” below (not into) “Copy Bundle Resources” in “Build Phases” with the following:

"${BUILT_PRODUCTS_DIR}/LaunchAtLogin_LaunchAtLogin.bundle/Contents/Resources/copy-helper-swiftpm.sh"

And uncheck “Based on dependency analysis”.

The build phase cannot run with "User Script Sandboxing" enabled. With Xcode 15 or newer where it is enabled by default, disable "User Script Sandboxing" in build settings.

(It needs some extra works to have our script to comply with the build phase sandbox.) (I would name the run script Copy “Launch at Login Helper”)

Who's using it?

License

MIT

カテゴリー

依存関係

依存関係一覧 1 件

ソースリポジトリ

このパッケージを使用しているプロジェクト