Buscar pacotes, repositórios e categorias de apps

Detalhes do pacotev1.8.1

once

Quer executar um trecho de código uma vez periodicamente (Uma vez - Diariamente - Semanalmente - Mensalmente - Na nova compilação - Na nova versão - Qualquer período)? Nós cuidamos disso por você.

AndroidiOS
Downloads em 30 dias
3,3 mil
Curtidas
311
Pontos Pub
160

Instalar pacote

flutter pub add once

Visão geral do pacote

Orientação gerada a partir de informações públicas. Apenas para referência.

O pacote 'once' permite que desenvolvedores executem código exatamente uma vez com base em diversos gatilhos, como diariamente, semanalmente, mensalmente, em uma nova compilação do aplicativo ou em um novo lançamento de versão. Simplifica a implementação de ações únicas, como exibir telas de boas-vindas, coletar feedback do usuário ou inicializar dados após atualizações. Projetado com simplicidade e confiabilidade em mente, funciona perfeitamente em plataformas Android e iOS. O pacote é ideal para gerenciar lógica única baseada em período ou evento, sem necessidade de rastreamento manual de estado.

Casos de uso

  • Mostrar telas de introdução apenas uma vez por versão do aplicativo
  • Disparar a coleta de análise na primeira execução
  • Exibir apenas os registros de alterações na nova versão
  • Execute tarefas de inicialização após a reconstrução do aplicativo
  • Agende notificações únicas
  • Execute rotinas de configuração na primeira abertura do aplicativo

Principais recursos

  • Suporta vários tipos de gatilho (diário, semanal, mensal, etc.)
  • Persistência automática após reinícios do aplicativo
  • Não há necessidade de gerenciamento manual de estado
  • Leve e fácil de integrar
  • Funciona tanto no Android quanto no iOS
  • Detectar versão e número de compilação

Indicado para

  • Fluxos de integração do aplicativo
  • Recursos de engajamento do usuário
  • Análise e coleta de feedback
  • Tarefas de configuração pós-atualização
  • Ações simples agendadas de uma vez

Considerações

  • Não oferece suporte a intervalos de tempo personalizados além das opções pré-definidas
  • Depende do relógio do sistema do dispositivo para o tempo
  • Pode ser necessário lidar com casos especiais relacionados às mudanças de fuso horário
  • Limitado a uma única execução por tipo de gatilho
  • Não adequado para tarefas recorrentes

README original

Snapshot do README original do repositório-fonte vinculado. Consulte o repositório para o conteúdo mais recente.

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

Categorias

Dependências

Lista de dependências 2 itens

Repositório-fonte

Projetos que usam este pacote

Ainda não há dados.