Skip to content

Commit

Permalink
comply dart conventions, change supported os versions
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuajylin committed May 4, 2023
1 parent 96ce839 commit 9ca7ed5
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 20 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.0.2

* Update README
* Comply dart conventions
* Change supported OS version

## 1.0.1

* Update license
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A Flutter plugin for Passkey.

| Android | iOS | MacOS | Web | Linux | Windows |
| :-----: | :-: | :---: | :-: | :---: | :-----: |
| V | V | X | X | X | X |
| V | V | X | X | X | X |

## Usage

Expand Down Expand Up @@ -35,3 +35,6 @@ flutterPasskeyPlugin.getCredential(requestOptions).then((response) {
```

See the example app for more complex examples.

## Learn more
- https://github.com/AuthenTrend/rp-app-example
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.0.0"
version: "1.0.2"
flutter_test:
dependency: "direct dev"
description: flutter
Expand Down
4 changes: 2 additions & 2 deletions ios/flutter_passkey.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
#
Pod::Spec.new do |s|
s.name = 'flutter_passkey'
s.version = '1.0.1'
s.version = '1.0.2'
s.summary = 'A Flutter plugin for Passkey.'
s.description = <<-DESC
A Flutter plugin for Passkey.
Flutter plugin for using Passkey easily.
DESC
s.homepage = 'https://github.com/AuthenTrend/flutter_passkey'
s.license = { :file => '../LICENSE' }
Expand Down
27 changes: 18 additions & 9 deletions lib/flutter_passkey.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@

import 'package:flutter/services.dart';

import 'flutter_passkey_platform_interface.dart';

class FlutterPasskey {
Future<bool> isSupported() async {
final isSupported = await FlutterPasskeyPlatform.instance.getPlatformVersion().then((osVersion) {
if (osVersion == null) { return false; }
final isSupported = await FlutterPasskeyPlatform.instance
.getPlatformVersion()
.then((osVersion) {
if (osVersion == null) {
return false;
}
final list = osVersion.split(' ');
final version = int.tryParse(list[1].split('.').first) ?? 0;
switch (list.first) {
case 'iOS':
return (version >= 16);
return (version >= 15);
case 'Android':
return (version >= 12);
return (version >= 9);
default:
return false;
}
Expand All @@ -22,17 +25,23 @@ class FlutterPasskey {
}

Future<String> createCredential(String options) async {
final response = await FlutterPasskeyPlatform.instance.createCredential(options);
final response =
await FlutterPasskeyPlatform.instance.createCredential(options);
if (response == null) {
throw PlatformException(code: "null-response", message: "Unable to get response from Passkey.");
throw PlatformException(
code: "null-response",
message: "Unable to get response from Passkey.");
}
return response;
}

Future<String> getCredential(String options) async {
final response = await FlutterPasskeyPlatform.instance.getCredential(options);
final response =
await FlutterPasskeyPlatform.instance.getCredential(options);
if (response == null) {
throw PlatformException(code: "null-response", message: "Unable to get response from Passkey.");
throw PlatformException(
code: "null-response",
message: "Unable to get response from Passkey.");
}
return response;
}
Expand Down
9 changes: 6 additions & 3 deletions lib/flutter_passkey_method_channel.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,22 @@ class MethodChannelFlutterPasskey extends FlutterPasskeyPlatform {

@override
Future<String?> getPlatformVersion() async {
final version = await methodChannel.invokeMethod<String>('getPlatformVersion');
final version =
await methodChannel.invokeMethod<String>('getPlatformVersion');
return version;
}

@override
Future<String?> createCredential(String options) async {
final response = await methodChannel.invokeMethod<String>('createCredential', {'options': options});
final response = await methodChannel
.invokeMethod<String>('createCredential', {'options': options});
return response;
}

@override
Future<String?> getCredential(String options) async {
final response = await methodChannel.invokeMethod<String>('getCredential', {'options': options});
final response = await methodChannel
.invokeMethod<String>('getCredential', {'options': options});
return response;
}
}
6 changes: 4 additions & 2 deletions lib/flutter_passkey_platform_interface.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ abstract class FlutterPasskeyPlatform extends PlatformInterface {
}

Future<String?> createCredential(String options) {
throw UnimplementedError('createCredential(String options) has not been implemented.');
throw UnimplementedError(
'createCredential(String options) has not been implemented.');
}

Future<String?> getCredential(String options) {
throw UnimplementedError('getCredential(String options) has not been implemented.');
throw UnimplementedError(
'getCredential(String options) has not been implemented.');
}
}
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_passkey
description: A Flutter plugin for Passkey.
version: 1.0.1
description: Flutter plugin for using Passkey easily on iOS and Android platforms.
version: 1.0.2
homepage: https://github.com/AuthenTrend/flutter_passkey

environment:
Expand Down

0 comments on commit 9ca7ed5

Please sign in to comment.