Skip to content

Commit

Permalink
Migrate code (#18)
Browse files Browse the repository at this point in the history
closes #17
  • Loading branch information
Rodrigolmti committed Jun 30, 2021
1 parent da7fff0 commit 2ad24de
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 25 deletions.
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,5 @@ packages:
source: hosted
version: "2.1.0"
sdks:
dart: ">=2.12.0-0.0 <3.0.0"
dart: ">=2.12.0 <3.0.0"
flutter: ">=1.20.0"
43 changes: 21 additions & 22 deletions lib/castle.dart
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@

import 'dart:async';

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

class Castle {
static const MethodChannel _channel =
const MethodChannel('castle');

static Future<void> configure({@required publishableKey, debugLoggingEnabled, maxQueueLimit, flushLimit, useCloudflareApp, baseURLAllowList}) async {
static Future<void> configure({required publishableKey, debugLoggingEnabled, maxQueueLimit, flushLimit, useCloudflareApp, baseURLAllowList}) async {
await _channel.invokeMethod('configure', <String, dynamic>{
'publishableKey': publishableKey,
'debugLoggingEnabled': debugLoggingEnabled,
Expand Down Expand Up @@ -41,8 +40,8 @@ class Castle {
await _channel.invokeMethod('flush');
}

static Future<bool> flushIfNeeded(String url) async {
final bool flushIfNeeded = await _channel.invokeMethod('flushIfNeeded', <String, dynamic>{
static Future<bool?> flushIfNeeded(String url) async {
final bool? flushIfNeeded = await _channel.invokeMethod('flushIfNeeded', <String, dynamic>{
'url': url,
});
return flushIfNeeded;
Expand All @@ -52,48 +51,48 @@ class Castle {
await _channel.invokeMethod('reset');
}

static Future<String> get baseUrl async {
final String baseUrl = await _channel.invokeMethod('baseUrl');
static Future<String?> get baseUrl async {
final String? baseUrl = await _channel.invokeMethod('baseUrl');
return baseUrl;
}

static Future<String> get clientId async {
final String clientId = await _channel.invokeMethod('clientId');
static Future<String?> get clientId async {
final String? clientId = await _channel.invokeMethod('clientId');
return clientId;
}

static Future<String> get clientIdHeaderName async {
final String clientIdHeaderName = await _channel.invokeMethod('clientIdHeaderName');
static Future<String?> get clientIdHeaderName async {
final String? clientIdHeaderName = await _channel.invokeMethod('clientIdHeaderName');
return clientIdHeaderName;
}

static Future<String> get createRequestToken async {
final String token = await _channel.invokeMethod('createRequestToken');
static Future<String?> get createRequestToken async {
final String? token = await _channel.invokeMethod('createRequestToken');
return token;
}

static Future<String> get requestTokenHeaderName async {
final String requestTokenHeaderName = await _channel.invokeMethod('requestTokenHeaderName');
static Future<String?> get requestTokenHeaderName async {
final String? requestTokenHeaderName = await _channel.invokeMethod('requestTokenHeaderName');
return requestTokenHeaderName;
}

static Future<String> get userId async {
final String userId = await _channel.invokeMethod('userId');
static Future<String?> get userId async {
final String? userId = await _channel.invokeMethod('userId');
return userId;
}

static Future<String> get userSignature async {
final String userSignature = await _channel.invokeMethod('userSignature');
static Future<String?> get userSignature async {
final String? userSignature = await _channel.invokeMethod('userSignature');
return userSignature;
}

static Future<String> get userAgent async {
final String userAgent = await _channel.invokeMethod('userAgent');
static Future<String?> get userAgent async {
final String? userAgent = await _channel.invokeMethod('userAgent');
return userAgent;
}

static Future<int> get queueSize async {
final int queueSize = await _channel.invokeMethod('queueSize');
static Future<int?> get queueSize async {
final int? queueSize = await _channel.invokeMethod('queueSize');
return queueSize;
}
}
2 changes: 1 addition & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,5 @@ packages:
source: hosted
version: "6.1.0+1"
sdks:
dart: ">=2.12.0-0.0 <3.0.0"
dart: ">=2.12.0 <3.0.0"
flutter: ">=1.20.0"
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ author: Castle Intelligence, Inc
homepage: https://github.com/castle/castle-flutter

environment:
sdk: ">=2.7.0 <3.0.0"
sdk: '>=2.12.0 <3.0.0'
flutter: ">=1.20.0"

dependencies:
Expand Down

0 comments on commit 2ad24de

Please sign in to comment.