diff --git a/CHANGELOG.md b/CHANGELOG.md
index 03682b4..91e45cf 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,11 +1,8 @@
-## [1.1.0] - 2021/04/11
-
-Release 1.1.0.
-Fixed issue #1 (see https://github.com/gcappon/fitbitter/issues/1).
-Now tokens are stored using `flutter_secure_storage` instead of `get_it` and `shared_preferences`.
+## [1.1.1] - 2022/02/25
+Formatted according to `flutter format .`.
-## [1.0.0] - 2021/04/11
+## [1.0.0] - 2022/02/25
Release 1.0.0.
Added docs at https://gcappon.github.com/fitbitter/
diff --git a/README.md b/README.md
index e1cbe41..5c656e0 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,7 @@
# fitbitter
-
+
+
A Flutter package to make your life easier when dealing with Fitbit APIs.
## Buy me a coffee
diff --git a/example/lib/main.dart b/example/lib/main.dart
index 925bf1c..b9dcf49 100644
--- a/example/lib/main.dart
+++ b/example/lib/main.dart
@@ -10,12 +10,12 @@ class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
- //This specifies the app entrypoint
- initialRoute: HomePage.route,
- //This maps names to the set of routes within the app
- routes: {
- HomePage.route: (context) => HomePage(),
- },
+ //This specifies the app entrypoint
+ initialRoute: HomePage.route,
+ //This maps names to the set of routes within the app
+ routes: {
+ HomePage.route: (context) => HomePage(),
+ },
);
} //build
-}//MyApp
\ No newline at end of file
+} //MyApp
diff --git a/example/lib/screens/homePage.dart b/example/lib/screens/homePage.dart
index 5f0bb1c..2015e3f 100644
--- a/example/lib/screens/homePage.dart
+++ b/example/lib/screens/homePage.dart
@@ -59,8 +59,9 @@ class HomePage extends StatelessWidget {
ElevatedButton(
onPressed: () async {
await FitbitConnector.unauthorize(
- clientID: Strings.fitbitClientID,
- clientSecret: Strings.fitbitClientSecret,);
+ clientID: Strings.fitbitClientID,
+ clientSecret: Strings.fitbitClientSecret,
+ );
},
child: Text('Tap to unauthorize'),
),
diff --git a/example/pubspec.lock b/example/pubspec.lock
index 08ea7a1..d05a999 100644
--- a/example/pubspec.lock
+++ b/example/pubspec.lock
@@ -210,7 +210,7 @@ packages:
path: ".."
relative: true
source: path
- version: "1.1.0"
+ version: "1.1.1"
fixnum:
dependency: transitive
description:
diff --git a/lib/src/fitbitConnector.dart b/lib/src/fitbitConnector.dart
index 4708136..a7d1d92 100644
--- a/lib/src/fitbitConnector.dart
+++ b/lib/src/fitbitConnector.dart
@@ -17,7 +17,6 @@ import 'package:fitbitter/src/urls/fitbitAuthAPIURL.dart';
/// (see [FitbitConnector.isTokenValid] for more details).
class FitbitConnector {
-
/// The secure storage where to store the Fitbit tokens
static final storage = const FlutterSecureStorage();
@@ -37,15 +36,19 @@ class FitbitConnector {
Dio dio = Dio();
Response response;
- //Get access token
- final fitbitRefreshToken = await FitbitConnector.storage.read(key: 'fitbitRefreshToken');
- if(fitbitRefreshToken == null){
+ //Get access token
+ final fitbitRefreshToken =
+ await FitbitConnector.storage.read(key: 'fitbitRefreshToken');
+ if (fitbitRefreshToken == null) {
return;
- }//if
+ } //if
// Generate the fitbit url
final fitbitUrl = FitbitAuthAPIURL.refreshToken(
- userID: userID, clientID: clientID, clientSecret: clientSecret, fitbitRefreshToken: fitbitRefreshToken);
+ userID: userID,
+ clientID: clientID,
+ clientSecret: clientSecret,
+ fitbitRefreshToken: fitbitRefreshToken);
// Post refresh query to Fitbit API
response = await dio.post(
@@ -66,8 +69,10 @@ class FitbitConnector {
// Overwrite the tokens into the shared preferences
final accessToken = response.data['access_token'] as String;
final refreshToken = response.data['refresh_token'] as String;
- await FitbitConnector.storage.write(key: 'fitbitAccessToken', value: accessToken);
- await FitbitConnector.storage.write(key: 'fitbitRefreshToken', value: refreshToken);
+ await FitbitConnector.storage
+ .write(key: 'fitbitAccessToken', value: accessToken);
+ await FitbitConnector.storage
+ .write(key: 'fitbitRefreshToken', value: refreshToken);
//GetIt.instance()
// .setString('fitbitAccessToken', accessToken);
//GetIt.instance()
@@ -81,13 +86,15 @@ class FitbitConnector {
Dio dio = Dio();
late Response response;
- //Get access token
- final fitbitAccessToken = await FitbitConnector.storage.read(key: 'fitbitAccessToken');
- if(fitbitAccessToken == null){
+ //Get access token
+ final fitbitAccessToken =
+ await FitbitConnector.storage.read(key: 'fitbitAccessToken');
+ if (fitbitAccessToken == null) {
return false;
- }//if
+ } //if
- final fitbitUrl = FitbitAuthAPIURL.isTokenValid(fitbitAccessToken: fitbitAccessToken);
+ final fitbitUrl =
+ FitbitAuthAPIURL.isTokenValid(fitbitAccessToken: fitbitAccessToken);
//Get the response
try {
@@ -169,8 +176,10 @@ class FitbitConnector {
final refreshToken = response.data['refresh_token'] as String;
userID = response.data['user_id'] as String?;
- await FitbitConnector.storage.write(key: 'fitbitAccessToken', value: accessToken);
- await FitbitConnector.storage.write(key: 'fitbitRefreshToken', value: refreshToken);
+ await FitbitConnector.storage
+ .write(key: 'fitbitAccessToken', value: accessToken);
+ await FitbitConnector.storage
+ .write(key: 'fitbitRefreshToken', value: refreshToken);
//GetIt.instance()
// .setString('fitbitAccessToken', accessToken);
//GetIt.instance()
@@ -192,15 +201,18 @@ class FitbitConnector {
//String userID;
- //Get access token
- final fitbitAccessToken = await FitbitConnector.storage.read(key: 'fitbitAccessToken');
- if(fitbitAccessToken == null){
+ //Get access token
+ final fitbitAccessToken =
+ await FitbitConnector.storage.read(key: 'fitbitAccessToken');
+ if (fitbitAccessToken == null) {
return;
- }//if
+ } //if
// Generate the fitbit url
final fitbitUrl = FitbitAuthAPIURL.unauthorize(
- clientSecret: clientSecret, clientID: clientID, fitbitAccessToken: fitbitAccessToken);
+ clientSecret: clientSecret,
+ clientID: clientID,
+ fitbitAccessToken: fitbitAccessToken);
// Post revoke query to Fitbit API
try {
diff --git a/lib/src/managers/fitbitDataManager.dart b/lib/src/managers/fitbitDataManager.dart
index bf79bf5..5f1371b 100644
--- a/lib/src/managers/fitbitDataManager.dart
+++ b/lib/src/managers/fitbitDataManager.dart
@@ -39,7 +39,8 @@ abstract class FitbitDataManager {
Dio dio = Dio();
late Response response;
- final fitbitAccessToken = await FitbitConnector.storage.read(key: 'fitbitAccessToken');
+ final fitbitAccessToken =
+ await FitbitConnector.storage.read(key: 'fitbitAccessToken');
try {
// get the fitbit profile data
response = await dio.get(
@@ -47,8 +48,7 @@ abstract class FitbitDataManager {
options: Options(
contentType: Headers.formUrlEncodedContentType,
headers: {
- 'Authorization':
- 'Bearer ${fitbitAccessToken}',
+ 'Authorization': 'Bearer $fitbitAccessToken',
},
),
);
diff --git a/lib/src/urls/fitbitAuthAPIURL.dart b/lib/src/urls/fitbitAuthAPIURL.dart
index e5b4a81..75d8807 100644
--- a/lib/src/urls/fitbitAuthAPIURL.dart
+++ b/lib/src/urls/fitbitAuthAPIURL.dart
@@ -31,7 +31,10 @@ class FitbitAuthAPIURL extends FitbitAPIURL {
/// Factory constructor that generates a [FitbitAuthAPIURL] to be used
/// to refresh the access token.
factory FitbitAuthAPIURL.refreshToken(
- {String? userID, String? clientID, String? clientSecret, required String fitbitRefreshToken}) {
+ {String? userID,
+ String? clientID,
+ String? clientSecret,
+ required String fitbitRefreshToken}) {
// Generate the authorization header
Codec stringToBase64 = utf8.fuse(base64);
final String authorizationHeader =
@@ -90,7 +93,9 @@ class FitbitAuthAPIURL extends FitbitAPIURL {
/// Factory constructor that generates a [FitbitAuthAPIURL] to be used
/// to revoke the access and refresh tokens.
factory FitbitAuthAPIURL.unauthorize(
- {String? clientID, String? clientSecret, required String fitbitAccessToken}) {
+ {String? clientID,
+ String? clientSecret,
+ required String fitbitAccessToken}) {
// Generate the authorization header
Codec stringToBase64 = utf8.fuse(base64);
final String authorizationHeader =
@@ -99,8 +104,7 @@ class FitbitAuthAPIURL extends FitbitAPIURL {
return FitbitAuthAPIURL(
userID: null,
url: '${_getBaseURL()}/revoke',
- data:
- 'token=$fitbitAccessToken',
+ data: 'token=$fitbitAccessToken',
authorizationHeader: 'Basic $authorizationHeader',
);
} // FitbitAuthAPIURL.unauthorize
@@ -111,10 +115,8 @@ class FitbitAuthAPIURL extends FitbitAPIURL {
return FitbitAuthAPIURL(
userID: null,
url: 'https://api.fitbit.com/1.1/oauth2/introspect',
- data:
- 'token=$fitbitAccessToken',
- authorizationHeader:
- 'Bearer $fitbitAccessToken',
+ data: 'token=$fitbitAccessToken',
+ authorizationHeader: 'Bearer $fitbitAccessToken',
);
} // FitbitAuthAPIURL.isTokenValid
diff --git a/pubspec.yaml b/pubspec.yaml
index 6cf2947..b617d31 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,6 +1,6 @@
name: fitbitter
description: A Flutter package to make your life easier when dealing with Fitbit APIs.
-version: 1.1.0
+version: 1.1.1
homepage: https://github.com/gcappon/fitbitter
environment: