패키지, 저장소 및 앱 카테고리 검색

패키지 상세v1.8.1

once

정기적으로 코드 조각을 한 번 실행하고 싶으신가요 (한 번만 - 매일 - 매주 - 매월 - 새 빌드 시 - 새 버전 시 - 어떤 기간이든)? 우리는 당신을 도와드립니다.

AndroidiOS
30일 다운로드
3.3천
좋아요
311
Pub 점수
160

패키지 설치

flutter pub add once

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

'once' 패키지는 매일, 주간, 월간, 새 앱 빌드 또는 새 버전 출시와 같은 다양한 트리거를 기반으로 코드를 정확히 한 번만 실행할 수 있도록 해줍니다. 환영 화면 표시, 사용자 피드백 수집, 업데이트 후 데이터 초기화와 같은 일회성 작업의 구현을 간소화합니다. 단순성과 신뢰성을 중심으로 설계되어 Android 및 iOS 플랫폼에서 원활하게 작동합니다. 수동 상태 추적 없이 주기적 또는 이벤트 기반의 일회성 로직을 관리하는 데 이상적입니다.

사용 사례

  • 앱 버전당 한 번만 온보딩 화면 표시
  • 첫 번째 시작 시 분석 수집 트리거
  • 새로운 버전에서만 업데이트 변경 사항을 표시
  • 앱 재빌드 후 초기화 작업 실행
  • 일회성 알림 예약
  • 앱을 처음 열 때 설정 루틴 실행

주요 기능

  • 다양한 트리거 유형(일간, 주간, 월간 등)을 지원합니다
  • 앱 재시작 간 자동 지속성
  • 수동 상태 관리 필요 없음
  • 경량이며 통합이 쉬움
  • 안드로이드 및 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 개

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.