flutter_safetynet_attestation 0.1.0

Flutter SafetyNet Attestation plugin for Android #

What is SafetyNet? #

The SafetyNet Attestation API helps you assess the security and compatibility of the Android environments in which your apps run. You can use this API to analyze devices that have installed your app.'

Please check the documentation here.

Getting Started #

iOS #

The plugin won't work iOS, because SafetyNet is only available for Android devices.

Android #

  1. Open the Google APIs console and enable Android Device Verification API
  2. Create your API key
  3. In your Android project, please add the SafetyNet API key in your AndroidManifest.xml:
<meta-data android:name="safetynet_api_key"

Dart #

The SafetyNet API is requiring a working version of the Google Play Services. A method is available to check if they are available on the device:


Then you have to pass a nonce (in a String or a byte array) to the following method:


It will then return a JWT string. Google recommends to check this JWT on your server. Please read the official documentation for more details.

If you want to get directly the payload from the JWT string, you can call instead:


You will then receive a JWSPayload object with this kind of content:

  "nonce": "R2Rra24fVm5xa2Mg",
  "timestampMs": 9860437986543,
  "apkPackageName": "com.package.name.of.requesting.app",
  "apkCertificateDigestSha256": ["base64 encoded, SHA-256 hash of the
                                  certificate used to sign requesting app"],
  "apkDigestSha256": ["base64 encoded, SHA-256 hash of
                      the APK installed on a user's device"],
  "ctsProfileMatch": true,
  "basicIntegrity": true,

[0.1.3] - 26th January 2018

  • [Breaking change] Migration to AndroidX

[0.0.3] - 21th January 2018

  • The JWSPayload can now be exported in a JSON format

[0.0.2] - 26th October 2018

  • SafetyNet dependency updated to 16.0.0
  • Check that the nonce has at least a length of 16
  • The INTERNET permission is now requested by the plugin
  • Instead of the error code, the message now contains a brief explanation (from CommonStatusCodes)

[0.0.1] - 6th July 2018

  • Initial release.


flutter_safetynet_attestation_example #

Demonstrates how to use the flutter_safetynet_attestation plugin.

Getting Started #

For help getting started with Flutter, view our online documentation.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  flutter_safetynet_attestation: ^0.1.0

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:flutter_safetynet_attestation/flutter_safetynet_attestation.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Feb 21, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5
  • Flutter: 1.12.13+hotfix.7

Maintenance suggestions

The package description is too short. (-8 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is getting outdated. (-7.12 points)

The package was last published 55 weeks ago.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.28.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8