GithubHelp home page GithubHelp logo

julianassmann / flutter_is_first_run Goto Github PK

View Code? Open in Web Editor NEW
10.0 2.0 3.0 57 KB

A simple flutter package to check if it is the first time the app runs. Hosted on pub.dev (see website link).

Home Page: https://pub.dev/packages/is_first_run

License: BSD 3-Clause "New" or "Revised" License

Kotlin 2.24% Swift 6.38% Objective-C 0.60% Dart 90.78%
flutter plugin

flutter_is_first_run's Introduction

is_first_run

A simple package to check if it is the first time the app runs.

Internally it uses the shared_preferences plugin.

Getting Started

To use this plugin, add is_first_run as a dependency in your pubspec.yaml file.

Usage

Import is_first_run.dart:

import 'package:is_first_run/is_first_run.dart';

To check if this is the first time the app is run:

bool firstRun = await IsFirstRun.isFirstRun();

If it is the first call of this method since installing the app, the method will return true for as long as the app keeps running.After a restart of the app it returns false.

There is also a method that allows you to check if it is the first time you call it:

bool firstCall = await IsFirstRun.isFirstCall();

Calling this function for the first time after installing the app returns true, after that every function call returns false.

You can reset the plugin by calling

await IsFirstRun.reset();

After calling reset(), calling isFirstRun() will return true as long as the app is running. After a restart, it will return false again. The first call of isFirstCall() will return true, subsequent calls will return false again.

Example

The example is a simple page showing you the result of the function IsFirstRun.isFirstRun(). A button allows you to call IsFirstRun.isFirstRun() again, the reset button calls IsFirstRun.reset().

Maintainers

Pull requests are always very welcome.

flutter_is_first_run's People

Contributors

julianassmann avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

flutter_is_first_run's Issues

Android devices: "first run" wrongly reported after uninstallation/reinstallation, when Google backup is ON on an Android device

The code assumes that _firstRunSettingsKey does not exist in shared preferences immediately after the app installation.

However, if the Android device's automatic backups setting is ON, the device data will be backed up once per day (and saved in the user's Google Drive account).

After the first backup is made, an uninstall/install will first automatically restore (behind the scene) any previously backed-up app data (shared preferences included), BEFORE the app is started "for real".
Therefore, _firstRunSettingsKey will be present when the app starts, and so the package will report that the app isn't run for the first time, which is not correct, since it was uninstalled & installed.

NB: this can be reproduced (1) if automatic Google backups is set to ON on the Android device, (2) after more than 1 day after the first installation, allowing time to Android to automatically backup the app data, and (3) if the device has an internet connection, which is usually the case.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.