Closed sini25 closed 2 years ago
Hi! No worries. I think it is showing data only in the debug console. That's why nothing is visible in the UI.
Just now I checked and these are the output in debug console.
E/flutter (10822): #0 FitbitDataManager.manageError (package:fitbitter/src/managers/fitbitDataManager.dart:87:38)
E/flutter (10822): #1 FitbitDataManager.getResponse (package:fitbitter/src/managers/fitbitDataManager.dart:56:25)
E/flutter (10822):
Or maybe the snap bar disappears after navigating to the fitbit auth browser?
Hi! No worries. I think it is showing data only in the debug console. That's why nothing is visible in the UI.
If it is really showing in debug console, then is there a way to make it view under UI? Please help me. I badly need this for my project.
Hi. I rechecked the code.
In example/lib/screens/homePage.dart you have this snippet of code:
ElevatedButton(
onPressed: () async {
// Authorize the app
String? userId = await FitbitConnector.authorize(
context: context,
clientID: Strings.fitbitClientID,
clientSecret: Strings.fitbitClientSecret,
redirectUri: Strings.fitbitRedirectUri,
callbackUrlScheme: Strings.fitbitCallbackScheme);
print(userId);
//Instantiate a proper data manager
FitbitActivityTimeseriesDataManager
fitbitActivityTimeseriesDataManager =
FitbitActivityTimeseriesDataManager(
clientID: Strings.fitbitClientID,
clientSecret: Strings.fitbitClientSecret,
type: 'steps',
);
//Fetch data
final stepsData = await fitbitActivityTimeseriesDataManager
.fetch(FitbitActivityTimeseriesAPIURL.dayWithResource(
date: DateTime.now().subtract(Duration(days: 1)),
userID: userId,
resource: fitbitActivityTimeseriesDataManager.type,
)) as List<FitbitActivityTimeseriesData>;
// Use them as you want
final snackBar = SnackBar(
content: Text(
'Yesterday you walked ${stepsData[0].value} steps!'));
ScaffoldMessenger.of(context).showSnackBar(snackBar);
},
child: Text('Tap to authorize'),
),
So, if you tap the button, this chain of events happens:
stepsData
.This is it. Of course this is just an example to show how to authorise the app and get data at the same time. In your actual app you have to think about some logic to properly perform these actions, but this is not related to the fitbitter package.
It works only until step 4 for me. Step 5 not showing anything. I try to run example code separately before I add them into my app. yet still it remain same. Once back to the app it supposed to show a snackbar but there isn't any snackBar appearing.
In the debug console, can you see the tokens, responses, etc...?
ill attached my debug console
Fitbitter is not working because there is a PlatformException. I think you are not setting your app correctly (redirectUri, clientId, clientSecret, callbackScheme). Check them and everything should work. I will close this issue since this is not actually related to fitbitter but it is on your side.
owh i see.Thankz for letting me know that.
Hi, sorry for asking a lot of questions. I really need the help here. Somehow the example app code is working but the problem is that it's not displaying any fetched data on the home page. Please help me.