flutter_keychain_plus 0.0.4 copy "flutter_keychain_plus: ^0.0.4" to clipboard
flutter_keychain_plus: ^0.0.4 copied to clipboard

Flutter secure storage via Keychain and Keystore

example/lib/main.dart

import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter_keychain_plus/flutter_keychain_plus.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String id = "";
  String value = "";

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: SizedBox(
          width: double.maxFinite,
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              if (Platform.isAndroid) Text('Android Device ID: $id'),
              Text('Getting Data : $value'),
              ElevatedButton(
                  onPressed: () async {
                    String? data = await FlutterKeychainPlus.get(key: "key");
                    setState(() {
                      value = data ?? "";
                    });
                  },
                  child: Text('Get')),
              ElevatedButton(
                  onPressed: () {
                    FlutterKeychainPlus.put(key: "key", value: "1234567890");
                  },
                  child: Text('Put')),
              ElevatedButton(
                  onPressed: () async {
                    await FlutterKeychainPlus.remove(key: "key");
                    setState(() {
                      value = "";
                    });
                  },
                  child: Text('Remove')),
              ElevatedButton(
                  onPressed: () async {
                    await FlutterKeychainPlus.clear();
                    setState(() {
                      value = "";
                    });
                  },
                  child: Text('Clear')),
              if (Platform.isAndroid)
                ElevatedButton(
                    onPressed: () async {
                      String? data = await FlutterKeychainPlus.getDeviceId();
                      setState(() {
                        id = data ?? "";
                      });
                    },
                    child: Text('getDeviceId')),
            ],
          ),
        ),
      ),
    );
  }
}
1
likes
130
points
175
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter secure storage via Keychain and Keystore

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on flutter_keychain_plus

Packages that implement flutter_keychain_plus