搜索插件、代码仓与 APP 分类

插件详情v1.0.0

is_first_run

一个简单的包,用于检查应用是否首次运行。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
2680
喜欢数
92
Pub 分数
160

安装插件

flutter pub add is_first_run

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

is_first_run 包提供了一种简单的方法来确定应用程序是否是首次在设备上启动。它使用共享偏好设置来存储一个标志,以指示应用的运行状态,确保跨会话的可靠检测。非常适合用于初始化设置流程、显示引导屏幕或触发首次用户操作。该包轻量且与所有主要 Flutter 平台兼容,包括移动设备、网页和桌面端。无需复杂配置,可无缝集成到现有项目中。

适合场景

  • 引导屏幕显示
  • 首次用户设置
  • 初始数据初始化
  • 欢迎消息传递
  • 功能切换激活

主要特点

  • 简单 API
  • 持久化状态存储
  • 跨平台支持
  • 无外部依赖
  • 轻松集成

适合对象

  • 新应用发布
  • 用户引导流程
  • 初始配置任务
  • 轻量级状态跟踪
  • 需要首次运行逻辑的应用程序

使用建议

  • 依赖于共享偏好
  • 不会自动重置
  • 可能需要手动清除
  • 仅限首次运行检测
  • 无内置分析功能

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

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.

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目