Skip to content

Commit

Permalink
Add setup for secured storage view
Browse files Browse the repository at this point in the history
  • Loading branch information
jdeguzman committed May 16, 2019
1 parent b914c24 commit 6868d78
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 5 deletions.
3 changes: 3 additions & 0 deletions lib/screens/dashboard.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// license that can be found in the LICENSE file.

import 'package:flutter/material.dart';
import 'package:flutter_persistence_demo/widgets/secured_storage_view.dart';
import 'package:flutter_persistence_demo/widgets/shared_preference_view.dart';

class DashboardScreen extends StatefulWidget {
Expand All @@ -25,6 +26,8 @@ class DashboardScreenState extends State<DashboardScreen> {
child: Column(
children: <Widget>[
SharedPreferenceView(),
Padding(padding: EdgeInsets.only(bottom: 30)),
SecuredStorageView(),
],
),
),
Expand Down
102 changes: 102 additions & 0 deletions lib/widgets/secured_storage_view.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// Copyright 2019 Joshua de Guzman (https://jmdg.io). All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

import 'package:flutter/material.dart';

class SecuredStorageView extends StatefulWidget {
@override
State<StatefulWidget> createState() {
return SecuredStorageViewState();
}
}

class SecuredStorageViewState extends State<SecuredStorageView> {
final String KEY_API_TOKEN = 'api_token';
String _data = "";

@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Secure storage of credential using\nflutter_secure_storage ^3.2.1+1',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Colors.blue,
),
),
Padding(padding: EdgeInsets.only(bottom: 5)),
Text(
'Stores data in Keychain (for iOS) and Keystore (for Android).',
style: TextStyle(
fontSize: 14,
),
),
Padding(padding: EdgeInsets.only(bottom: 10)),
ClipRRect(
borderRadius: BorderRadius.circular(10),
child: Container(
color: Colors.blue,
height: 150,
padding: EdgeInsets.all(10),
width: double.infinity,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text(
'API TOKEN',
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
Padding(padding: EdgeInsets.only(bottom: 5)),
Text(
'$_data',
style: TextStyle(
fontSize: 30,
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
Padding(padding: EdgeInsets.only(bottom: 10)),
Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
RaisedButton(
child: Text('Generate'),
onPressed: _generatePassword,
),
Padding(padding: EdgeInsets.all(10)),
RaisedButton(
child: Text('Save'),
onPressed: _savePassword,
),
Padding(padding: EdgeInsets.all(10)),
RaisedButton(
child: Text('Read'),
onPressed: _readPassword,
),
],
),
],
),
),
)
],
);
}

_generatePassword() async {}

_savePassword() async {}

_readPassword() async {}
}
11 changes: 6 additions & 5 deletions lib/widgets/shared_preference_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ class SharedPreferenceViewState extends State<SharedPreferenceView> {
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Storing simple data (shared_preferences 0.5.2)',
'Storing simple data locally using\nshared_preferences ^0.5.2',
style: TextStyle(
fontSize: 14,
fontSize: 16,
fontWeight: FontWeight.bold,
color: Colors.blue,
),
Expand All @@ -50,18 +50,19 @@ class SharedPreferenceViewState extends State<SharedPreferenceView> {
borderRadius: BorderRadius.circular(10),
child: Container(
color: Colors.blue,
height: 175,
height: 150,
padding: EdgeInsets.all(10),
width: double.infinity,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Text(
'Counter (int)',
'COUNTER',
style: TextStyle(
fontSize: 20,
fontSize: 16,
color: Colors.white,
fontWeight: FontWeight.bold,
),
),
Padding(padding: EdgeInsets.only(bottom: 5)),
Expand Down
7 changes: 7 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_secure_storage:
dependency: "direct main"
description:
name: flutter_secure_storage
url: "https://pub.dartlang.org"
source: hosted
version: "3.2.1+1"
flutter_test:
dependency: "direct dev"
description: flutter
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ dependencies:
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
shared_preferences: ^0.5.2
flutter_secure_storage: ^3.2.1+1

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit 6868d78

Please sign in to comment.