Copy public key to clipboard

This commit is contained in:
Vishesh Handa
2019-01-10 18:33:12 +01:00
parent 1c315836d3
commit 1ad2a2cb62

View File

@ -1,4 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:shared_preferences/shared_preferences.dart'; import 'package:shared_preferences/shared_preferences.dart';
import 'package:journal/storage/git.dart'; import 'package:journal/storage/git.dart';
@ -16,6 +17,7 @@ class OnBoardingScreen extends StatefulWidget {
class OnBoardingScreenState extends State<OnBoardingScreen> { class OnBoardingScreenState extends State<OnBoardingScreen> {
var pageController = PageController(); var pageController = PageController();
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@ -32,12 +34,15 @@ class OnBoardingScreenState extends State<OnBoardingScreen> {
pref.setString("sshCloneUrl", sshUrl); pref.setString("sshCloneUrl", sshUrl);
}); });
}), }),
OnBoardingSshKey(doneFunction: () { OnBoardingSshKey(
doneFunction: () {
pageController.nextPage( pageController.nextPage(
duration: Duration(milliseconds: 200), duration: Duration(milliseconds: 200),
curve: Curves.easeIn, curve: Curves.easeIn,
); );
}), },
scaffoldKey: _scaffoldKey,
),
OnBoardingGitClone( OnBoardingGitClone(
doneFunction: this.widget.onBoardingCompletedFunction, doneFunction: this.widget.onBoardingCompletedFunction,
), ),
@ -45,6 +50,7 @@ class OnBoardingScreenState extends State<OnBoardingScreen> {
); );
return new Scaffold( return new Scaffold(
key: _scaffoldKey,
body: new Container( body: new Container(
width: double.infinity, width: double.infinity,
height: double.infinity, height: double.infinity,
@ -135,8 +141,12 @@ class OnBoardingGitUrlState extends State<OnBoardingGitUrl> {
class OnBoardingSshKey extends StatefulWidget { class OnBoardingSshKey extends StatefulWidget {
final Function doneFunction; final Function doneFunction;
final GlobalKey<ScaffoldState> scaffoldKey;
OnBoardingSshKey({@required this.doneFunction}); OnBoardingSshKey({
@required this.doneFunction,
@required this.scaffoldKey,
});
@override @override
OnBoardingSshKeyState createState() { OnBoardingSshKeyState createState() {
@ -153,6 +163,14 @@ class OnBoardingSshKeyState extends State<OnBoardingSshKey> {
setState(() { setState(() {
print("Changing the state"); print("Changing the state");
publicKey = _publicKey; publicKey = _publicKey;
Clipboard.setData(ClipboardData(text: publicKey));
var text = "Public Key copied to Clipboard";
this
.widget
.scaffoldKey
.currentState
.showSnackBar(new SnackBar(content: new Text(text)));
}); });
}); });
} }