Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: CI

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
package:
name: Analyze & test (package)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5

- uses: subosito/flutter-action@v2
with:
channel: stable
cache: true

- name: Install dependencies
run: flutter pub get

- name: Verify generated code is up to date
run: |
dart run build_runner build
if ! git diff --quiet; then
echo "::error::Generated *.g.dart files are out of date. Run: dart run build_runner build"
git --no-pager diff --stat
exit 1
fi

- name: Analyze
run: dart analyze --fatal-infos --fatal-warnings

- name: Test
run: flutter test

example:
name: Analyze (example)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5

- uses: subosito/flutter-action@v2
with:
channel: stable
cache: true

- name: Create example secret
working-directory: example
run: cp lib/secret.dart.example lib/secret.dart

- name: Install dependencies
working-directory: example
run: flutter pub get

- name: Analyze
working-directory: example
run: flutter analyze
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
gir# strava_flutter
# strava_flutter

[![CI](https://github.com/dreampowder/strava_flutter/actions/workflows/ci.yml/badge.svg)](https://github.com/dreampowder/strava_flutter/actions/workflows/ci.yml)

Dart/flutter package to use Strava API v3

Expand Down
17 changes: 17 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
include: package:flutter_lints/flutter.yaml

analyzer:
exclude:
# Generated by json_serializable / build_runner.
- "**/*.g.dart"
# The example is a standalone package with its own analysis + CI job.
- "example/**"
errors:
# Keep the published API tidy without failing the build on doc nits.
todo: ignore

linter:
rules:
# The package exposes snake_case enum values that mirror Strava's API
# (e.g. AuthenticationScope.read_all); don't fight the wire format.
constant_identifier_names: false
2 changes: 1 addition & 1 deletion lib/src/common/local_storage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:strava_client/src/domain/model/model_authentication_response.dar
import 'package:strava_client/src/domain/model/model_authentication_scopes.dart';

class LocalStorageManager {
static String _kTokenKey = "strava_token";
static const String _kTokenKey = "strava_token";
// static String _kScopesKey = "strava_scopes";

static Future<bool> saveToken(
Expand Down
2 changes: 1 addition & 1 deletion lib/src/common/session_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class SessionManager {
if (_currentToken != null) {
completer.complete(_currentToken);
} else {
LocalStorageManager.getToken(applicationName: this.applicationName)
LocalStorageManager.getToken(applicationName: applicationName)
.then((storedValue) {
if (storedValue != null) {
_currentToken = storedValue;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/data/repository/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class ApiClient {
var dio = Dio();
if (isAuthenticated) {
var token = await sl<SessionManager>().getValidToken();
var headers = Map<String, dynamic>();
var headers = <String, dynamic>{};
if (token != null) {
headers.putIfAbsent(
"Authorization", () => "Bearer ${token.accessToken}");
Expand Down
4 changes: 2 additions & 2 deletions lib/src/data/repository/repository_authentication_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class RepositoryAuthenticationImpl extends RepositoryAuthentication {
final Completer<String> completer = Completer<String>();
final params =
'?client_id=${sl<SessionManager>().clientId}&redirect_uri=$redirectUrl&response_type=code&approval_prompt=${forceShowingApproval ? "force" : "auto"}&scope=${AuthenticationScopeHelper.buildScopeString(scopes)}';
final _appLinks = AppLinks();
final appLinks = AppLinks();

var host = "https://www.strava.com/";

Expand All @@ -114,7 +114,7 @@ class RepositoryAuthenticationImpl extends RepositoryAuthentication {
didLaunchNativeApp = true;
host = "strava://";
_uriLinkStream?.cancel();
_uriLinkStream = _appLinks.uriLinkStream.listen((uri) {
_uriLinkStream = appLinks.uriLinkStream.listen((uri) {
final error = uri.queryParameters['error'];
final code = uri.queryParameters['code'];
if (error != null) {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/domain/model/model_activity_type_enum.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ extension ActivityTypeEnumHelper on ActivityTypeEnum {
}

String stringValue() {
return this.toString().split(".").last;
return toString().split(".").last;
}
}
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ dev_dependencies:
sdk: flutter
build_runner: ^2.15.0
json_serializable: ^6.14.0
flutter_lints: ^5.0.0
# test: 1.5.3 # To launch some tests in /test

# For information on the generic Dart part of this file, see the
Expand Down