A Dart wrapper to provide a more Object-Oriented method of accessing the Concept2 Logbook API from Flutter Applications
Based on the list of available endpoints from Concept2's documentation Results
csv
, fit
, or tcx
fileProfile
Stroke Data
Challenges
Webhooks TBD
Infrastructure
c2logbook
consumersThis package relies on user-supplied Client ID and Client Secret values provided by Concept2.
Go to the Concept2 key creation page for either the development site or the production site
Log in or create an account if necessary and create a new application
example
code and use http://localhost:8000/static/callback.html
(or use your own domain and callback url if you know you need something else)run the flutter frontend code using the command: flutter run -d chrome --dart-define C2_LOGBOOK_CLIENT_ID=[CLIENT ID HERE] --dart-define C2_LOGBOOK_CLIENT_SECRET=[CLIENT SECRET HERE] --web-port=8000
. This will open your web browser to the local host version of the Flutter website.
c2logbook
folder present in the same directory as this project, as it is a flutter library that I built to handle the more complex aspects of the Concept2 API, such as dealing with Oauth.http://localhost:8000/static/callback.html
is registered as a callback URL on concept2's developers/keys
portal. You can pick a different port as long as the --web-port
argument in the above command has the same port numberensure that the python bridge is also running and able to serve HTTP requests. this is available in a separate repository and should be run on port 8080
Initializing the Logbook API looks like this:
const concept2Logbook = C2Logbook(
development: true, // if you want to use the production domain, remove this item or set it to false
redirectUri: 'YOUR_CALLBACK_URL_HERE',
clientId: const String.fromEnvironment("C2_LOGBOOK_CLIENT_ID"),
clientSecret: const String.fromEnvironment("C2_LOGBOOK_CLIENT_SECRET")
);
You can also make this object available using a Provider
Fetching the current user:
C2User me = await concept2Logbook.me();
This returns a C2User
object containing various properties that can then be displayed in the UI or otherwise used:
//...
children = [
Text("Hello ${me.firstName} ${me.lastName}"),
Text("Your Country: ${me.country}"),
Text("Your Gender: ${me.gender}"),
Text("Your Birthday: ${me.dob}")
]
//...
dart run build_runner build
is needed to generate code before things will likely work (if running locally)
dart run build_runner build
flutter test
This package is still in a relatively early stage of development. Things might break. I'll do my best to fix these issues and add new features in a timely manner. Please file a Github Issue if you find any bugs, or start a discussion if you have feature requests or want to ask questions.