Flutter SDK reference
The revokegpt plugin returns a RevokeGPT token from a Flutter app on iOS and Android. It is a thin layer over the native iOS and Android SDKs, which do the proof of work, App Attest (iOS) or Play Integrity (Android), and show the hosted challenge sheet when your site’s rules ask for one. Your server verifies the token with siteverify. For a walkthrough, see the Flutter quickstart.
Plugin version: 0.1.0. It moves in lockstep with the native iOS and Android SDKs. Requires iOS 15 or later, Android 7.0 (API 24) or later, and Flutter 3.47.9 or later. Your app’s compileSdk must be 37 or higher.
Install
Section titled “Install”dependencies: revokegpt: path: ../path/to/sdks/flutter # until the first release; then: revokegpt: 0.1.0From source you also need the native pieces. On iOS, run node tools/mobile-vendor/src/cli.ts vendor once at the repository root. On Android, until the native SDK is on Maven Central, add it to your app’s android/settings.gradle.kts as a composite build that substitutes com.revokegpt:revokegpt-android with the sdks/android project.
Do not also link the native iOS SDK into the same app: you would get two copies, each with its own state, sharing the same Keychain items.
import 'package:revokegpt/revokegpt.dart';Options
Section titled “Options”RevokeGPT.configure takes these named arguments. Each is checked in Dart before any native call, and a malformed one throws invalid-argument.
| Option | Type | Default | Notes |
|---|---|---|---|
siteKey |
String |
required | Your public site key: rgpk_ and 20 letters and digits. |
endpoint |
String? |
the hosted API | An https: URL. Plain http: is allowed only to a loopback host, in debug builds. On Android that includes the emulator’s 10.0.2.2. No userinfo, query or fragment. |
widgetOrigin |
String? |
the hosted widget origin | The hosted challenge page’s origin. Same scheme rules as endpoint, and no path. |
timeout |
Duration |
10 seconds | 1 to 60 seconds, for the network calls, proof of work and attestation. |
cloudProjectNumber |
String? |
none | Android only: your Google Cloud project number, a decimal number of up to 18 digits with no leading zero. Without it the SDK does not call Play. Ignored on iOS. |
locale |
String? |
the device’s | The hosted page’s language, such as en or pt-BR. |
theme |
RevokeGPTTheme |
RevokeGPTTheme.auto |
light, dark or auto. |
keyScope |
String? |
none | iOS only: an opaque id of the signed-in account, 1 to 1024 bytes of UTF-8, for one App Attest key per account. Use an opaque value, not an email. Ignored on Android. |
debugLogging |
bool |
false |
Logs event names only, never a token. |
Methods
Section titled “Methods”All methods are static on RevokeGPT.
RevokeGPT.configure
Section titled “RevokeGPT.configure”static Future<void> configure({ required String siteKey, String? endpoint, String? widgetOrigin, Duration timeout = const Duration(seconds: 10), String? cloudProjectNumber, String? locale, RevokeGPTTheme theme = RevokeGPTTheme.auto, String? keyScope, bool debugLogging = false,})Configures the SDK. A later call replaces the configuration. A call made while another call is running fails with busy.
Returns a Future<void> that completes when the native SDK is configured.
await RevokeGPT.configure(siteKey: 'rgpk_...', cloudProjectNumber: '123456789012');RevokeGPT.execute
Section titled “RevokeGPT.execute”static Future<String> execute({String? action, String? cdata})Returns a RevokeGPT token. When the site’s rules ask for a challenge, the native sheet is shown and the call returns when the person finishes or closes it.
| Parameter | Rules |
|---|---|
action |
1 to 100 characters of A-Z a-z 0-9 / _. |
cdata |
0 to 255 characters of A-Z a-z 0-9 _ -. |
Returns a Future<String> with the token. Send it to your server, which verifies it with siteverify.
try { final token = await RevokeGPT.execute(action: 'login'); // send `token` to your server with the request} on RevokeGPTException catch (e) { // e.code: 'challenge-required', 'cancelled', 'rate-limited', ...}RevokeGPT.challengeAccount
Section titled “RevokeGPT.challengeAccount”static Future<String> challengeAccount(String requestToken, {String? languageCode})Account verification: shows the hosted page for the request token your server got from RevokeGPT and returns that page’s token. requestToken is 1 to 2048 characters of A-Z a-z 0-9 _ -. languageCode is a language code of up to 35 characters, such as en or pt-BR. See account protection.
Returns a Future<String> with the page’s token.
RevokeGPT.version
Section titled “RevokeGPT.version”static const String versionThe plugin’s version string (0.1.0). The native SDKs share it. Both platforms send it, with the name revokegpt-flutter, in the request’s sdk field.
Other exports
Section titled “Other exports”RevokeGPTTheme is the enum light, dark, auto. RevokeGPTException is the error class below. revokeGPTErrorCodes is the list of every code the plugin reports.
Errors and failure model
Section titled “Errors and failure model”Every failure is a RevokeGPTException. It carries only:
| Field | Type | Meaning |
|---|---|---|
code |
String |
One of revokeGPTErrorCodes. |
status |
int? |
The HTTP status of an API error, when there was one. |
requestId |
String? |
The server’s request id, when it sent a well-formed one. |
retryAfterSeconds |
int? |
Retry-After on a 429 or 503, in whole seconds, at most 3600. |
It never carries a token, a site key or a message from a lower layer.
The SDK’s own codes are invalid-argument, not-configured, network-error, timeout, http-error, invalid-response, challenge-required, challenge-unsupported, cancelled, busy and internal. API error codes are passed through unchanged: bad-request, not-found, payload-too-large, invalid-site-key, hostname-not-allowed, site-disabled, challenge-expired, challenge-invalid, pow-invalid, rate-limited, quota-exceeded, internal-error, unsupported-media-type, app-not-allowed, plan-required and plan-restricted. See error codes.
How the plugin itself produces codes:
- A bad argument is
invalid-argument, thrown in Dart without calling the native side. - A native code that is not in the list becomes
internal. - A missing native plugin (a platform other than iOS and Android, or a plugin that is not registered) is
internal. - Closing the challenge sheet, or the Flutter engine detaching during a call, is
cancelled.
Treat every failure as “do not accept” for the action you are protecting.
Configuration
Section titled “Configuration”- iOS: add the App Attest capability to the Runner target. Use the
developmentenvironment while you develop andproductionfor TestFlight and the App Store. Add the iOS app (Team ID and bundle id) under Apps in the dashboard. Both Swift Package Manager and CocoaPods are supported. - Android: link a Google Cloud project and turn on the Play Integrity API in the Play Console, add the Android app (package name and the app-signing certificate’s SHA-256) in the dashboard, upload the service account’s JSON key, and pass the project number as
cloudProjectNumber. The only permission isINTERNET, which the SDK declares itself. R8 needs no rules from you. - Where attestation is unavailable (the iOS Simulator, an emulator without Play), the SDK still returns a token, but it carries no full attestation and RevokeGPT gives it a lower score.
- The challenge sheet is shown over the Flutter view controller on iOS and the attached Activity on Android.
Security notes
Section titled “Security notes”- The token is only a claim until your server verifies it. Verify with siteverify and your secret key (
rgsk_...) on the server, never in the app. - Verify app tokens with
expectedApp(platform and bundle id or package name), not a hostname. - The site key is public. The secret key must never be in the app.
- The plugin adds nothing to what the native SDKs send and store. It sends your site key, the app’s bundle id or package name, the
actionandcdatayou pass, the SDK name and version, the proof of work and the attestation result. It never reads advertising ids, accounts, location, contacts or installed apps. On iOS the only stored item is the App Attest key id, in the Keychain. Android stores nothing. debugLogginglogs event names only. Plainhttp:endpoints are refused outside debug builds.
See also the Flutter quickstart and mobile attestation.