once 1.1.2 copy "once: ^1.1.2" to clipboard
once: ^1.1.2 copied to clipboard

outdated

Want to run a piece of code once periodically (Daily - Weekly - Monthly - On new version - Any period)? We cover your back.

once #

For Once widgets use flutter_once #

Want to run a piece of code 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, runOnEveryNewVersion, runEvery12Hours, runHourly, runDaily, runWeekly, runMonthly, runOnNewMonth, runYearly and Custom (Duration).

Usage #

Mainly runner functions consists of callbacks and fallbacks

  • callback are the generic functions that run and returns a future<T?> .
  • fallback are the same but only runs in case if that callback future returns null.

Now you're ready to go. Say you wanted to show the new features dialog when the app is updated:

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 every week for the user:

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

Contributors #

inspired by the java library Once made by Jon Finerty

221
likes
0
pub points
89%
popularity

Publisher

verified publishermosoliman.tech

Want to run a piece of code once periodically (Daily - Weekly - Monthly - On new version - Any period)? We cover your back.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

package_info_plus, shared_preferences

More

Packages that depend on once