at_backupkey_flutter 1.0.0+3 copy "at_backupkey_flutter: ^1.0.0+3" to clipboard
at_backupkey_flutter: ^1.0.0+3 copied to clipboard

outdated

A flutter plugin project for saving backup key of any @sign that is being onboarded with @protocol apps. Backup key can used to authenticate in any @protocol apps.

example/lib/main.dart

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

import 'package:at_backupkey_flutter/at_backupkey_flutter.dart';
import 'package:at_onboarding_flutter/at_onboarding_flutter.dart';
import 'package:path_provider/path_provider.dart' as path_provider;

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

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

class _MyAppState extends State<MyApp> {
  bool loading = false;
  var atClientServiceMap;
  var atsign;
  var rootDomain = 'root.atsign.wtf';

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

  Future<AtClientPreference> getAtClientPreference() async {
    final appDocumentDirectory =
        await path_provider.getApplicationSupportDirectory();
    String path = appDocumentDirectory.path;
    var _atClientPreference = AtClientPreference()
      ..isLocalStoreRequired = true
      ..commitLogPath = path
      ..namespace = 'backupkeys'
      ..syncStrategy = SyncStrategy.ONDEMAND
      ..rootDomain = rootDomain
      ..hiveStoragePath = path;
    return _atClientPreference;
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Builder(
          builder: (context) => Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              Center(
                child: RaisedButton(
                  onPressed: () async {
                    var _atClientPreference = await getAtClientPreference();
                    Onboarding(
                        context: context,
                        domain: rootDomain,
                        atClientPreference: _atClientPreference,
                        onboard: (map, atsign) {
                          this.atClientServiceMap = map;
                          this.atsign = atsign;
                          loading = true;
                          setState(() {});
                        },
                        onError: (error) {});
                  },
                  child: Text('Onboard my @sign'),
                ),
              ),
              if (loading)
                BackupKeyWidget(
                  atsign: this.atsign,
                  atClientService: this.atClientServiceMap[atsign],
                  isIcon: true,
                )
            ],
          ),
        ),
      ),
    );
  }
}
5
likes
40
pub points
61%
popularity

Publisher

verified publisheratsign.org

A flutter plugin project for saving backup key of any @sign that is being onboarded with @protocol apps. Backup key can used to authenticate in any @protocol apps.

Homepage
Repository (GitHub)
View/report issues
Contributing

License

BSD-3-Clause (LICENSE)

Dependencies

at_client_mobile, at_utils, flutter, path_provider, permission_handler, share

More

Packages that depend on at_backupkey_flutter