flutter_keychainaccess 0.2.1 copy "flutter_keychainaccess: ^0.2.1" to clipboard
flutter_keychainaccess: ^0.2.1 copied to clipboard

PlatformiOS

A new flutter plugin project.

example/lib/main.dart

import 'dart:math';

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

import 'package:flutter/services.dart';
import 'package:flutter_keychainaccess/flutter_keychainaccess.dart';

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

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

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

  write() async {
    var value = Random().nextInt(1000).toString();
    await FlutterKeychainaccess.write(service: "testservice", key: "userToken", value: value);
    print('test');
  }

  remove() async {
    await FlutterKeychainaccess.remove(service: "testservice", key: "userToken");
    print('test');
  }

  read() async {
    var v = await FlutterKeychainaccess.read(service: "testservice", key: "userToken");
    setState(() => value = v);
  }

  readAll() async {
    var allItems = await FlutterKeychainaccess.allItems(service: "testservice");
    var v = allItems.values.join(", ");
    setState(() => value = v);
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            children: [
              RaisedButton(onPressed: write, child: Text("write")),
              RaisedButton(onPressed: remove, child: Text("remove")),
              RaisedButton(onPressed: read, child: Text("read")),
              RaisedButton(onPressed: read, child: Text("read all")),
              Text(value ?? 'unknown')
            ]
          )
        ),
      ),
    );
  }
}
2
likes
115
pub points
52%
popularity

Publisher

unverified uploader

A new flutter plugin project.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_keychainaccess