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

パッケージ詳細v1.8.1

once

一定期間ごとにコードの一部を一度実行したいですか(1回だけ - 日次 - 週次 - 月次 - 新しいビルド時 - 新しいバージョン時 - 任意の期間)?私たちが対応します。

AndroidiOS
30日間ダウンロード
3340
いいね数
311
Pub ポイント
160

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

flutter pub add once

パッケージ概要

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

「once」パッケージは、毎日、毎週、毎月、新しいアプリビルド、または新しいバージョンリリースなどのさまざまなトリガーに基づいて、コードを正確に1回実行できるようにします。ウェルカムスクリーンの表示、ユーザーからのフィードバック収集、アップデート後のデータ初期化などの一時的なアクションの実装を簡素化します。シンプルさと信頼性を重視して設計されており、AndroidおよびiOSプラットフォームでシームレスに動作します。手動での状態追跡なしに、定期的またはイベント駆動の一時的ロジックを管理するのに最適です。

用途

  • アプリバージョンごとにオンボーディング画面を1回だけ表示する
  • 初回起動時に分析収集をトリガーする
  • 新しいバージョンでのみ更新ログを表示する
  • アプリの再構築後に初期化タスクを実行する
  • 一時的な通知をスケジュールする
  • 初回アプリ起動時にセットアップ手順を実行する

主な機能

  • 複数のトリガー種別(毎日、毎週、毎月など)をサポートしています
  • アプリ再起動間の自動パーシステンス
  • 手動での状態管理は不要です
  • 軽量で統合が簡単
  • Android および iOS の両方で動作します
  • バージョンおよびビルド番号の検出

適している対象

  • アプリオンボーディングフロー
  • ユーザー参加機能
  • 分析とフィードバック収集
  • 更新後のセットアップタスク
  • シンプルなスケジュールされたワンタイムアクション

注意事項

  • 事前定義されたオプションを超えるカスタム時間間隔はサポートされていません
  • タイミングにデバイスのシステム時計に依存しています
  • タイムゾーンの変更に関するエッジケースを処理する必要がある可能性があります
  • トリガーの種類ごとに一度のみ実行可能
  • 繰り返しのタスクには適していません

元の README

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

once pub

Want to run/show a piece of code/widget once (Once - Hourly - Daily - Weekly - Monthly - Every new version - Any custom duration)? We cove your back.


Some things should happen once.

  • Users should only get the guided tour once.
  • Release notes should only pop up once every new app version comes.
  • Etc.. once every (Whatever you want).

Once supports runOnce, runUntilDone, runOnEveryNewVersion, runEvery12Hours, runHourly, runDaily, runOnNewDay, runWeekly, runMonthly, runOnNewMonth, runYearly and runCustom.

Some widgets should show once.

  • Users should only get this alert OnceWidget.
  • Hello it new version widget shows OnceWidget every new app version comes.
  • Etc.. OnceWidget every (Whatever you want).

OnceWidgets supports showOnce, showUntilDone, showOnEveryNewVersion, showEvery12Hours, showHourly, showDaily, showOnNewDay, showWeekly, showMonthly, showOnNewMonth, showYearly and showCustom.

Usage

Once

Mainly runner functions consists of callbacks and fallbacks

  • callback is the generic function that runs and returns a future<T?> .
  • fallback is the same but only runs in case that callback future returns null.

Now you're ready to go. Say you wanted to show the new features dialog when new version of the app come:

Once.runOnEveryNewVersion(
  callback: () {
    /* What's new in 2.3.2 version? dialog */
  },
  fallback: () {
   /* Navigate to new screen */
  },
);

Or maybe you want to show the rate this app dialog weekly:

if (!rated) {
  Once.runWeekly("ratingDialog",
    callback: () { 
       /* Like our app, Please rate us. dialog */ 
    },
    fallback: () {
      /* Thanks */
    },
  );
}

Or maybe you want to show a feature prompt until the user explicitly dismisses it:

Once.runUntilDone("feature_prompt",
  callback: (dismiss) { 
     /* Show feature prompt dialog */ 
     // Call dismiss() when the user clicks "Got it"
     dismiss();
  },
  fallback: () {
    /* Feature already acknowledged */
  },
);

OnceWidget

Mainly builder functions consists of builders and fallbacks

  • builder is the generic function that shows and returns a Widget and provide for BuildContext.
  • fallback is the same but only shows in case that callback future returns null (defaults to SizedBox.shrink()) and provide for BuildContext.

Now you're ready to go. Say you wanted to view a banner widget when the app is updated:

OnceWidget.showOnEveryNewVersion(
  builder: (context) {
   return Container(...);
  },
);

Or maybe you want to show the hello new week widget weekly:

OnceWidget.showWeekly("weekWidget",
  builder: (context) {
     return Text('Hello, New Week');
   },
  fallback: (context) {
     return Text('Hello!');
   },
);

Or maybe you want to show a banner until the user dismisses it:

OnceWidget.showUntilDone("onboarding_banner",
  builder: (dismiss) {
     return Row(
       children: [
         Text('New feature available!'),
         ElevatedButton(
           onPressed: dismiss, // Will not show again after being clicked
           child: Text('Got it'),
         ),
       ],
     );
   },
  fallback: () {
     return SizedBox.shrink();
   },
);

Additional

Functions
  • clear removes the Once or OnceWidget data for a specific key.
  • clearAll removes all the Once and OnceWidget data.
  • markDone manually flags a key as completed for untilDone operations.
Parameters
  • debugCallback used to debug the callback function.
  • debugFallback used to debug the fallback function.

Note: The debug parameters are only works in debug mode.

Contributors

Inspired by the Java library Once made by Jon Finerty

カテゴリー

依存関係

依存関係一覧 2 件

ソースリポジトリ

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

データはまだありません。