Код: Выделить всё
I/FLUTTER_HEALTH: Health Connect permissions were not granted! Make sure to declare the required permissions in the AndroidManifest.xml file.
Код: Выделить всё
final health = Health();
// Define the sleep-related data types we want
final types = [
HealthDataType.SLEEP_SESSION,
HealthDataType.SLEEP_REM,
HealthDataType.SLEEP_LIGHT,
HealthDataType.SLEEP_DEEP,
];
// Request authorization for the desired types
bool granted = await health.requestAuthorization(types);
if (!granted) {
print('Permission for sleep data was not granted.');
return;
}
final now = DateTime.now();
final from = now.subtract(const Duration(days: 7)); // Last 7 days
// Fetch sleep data using correct named parameters
List sleepData = await health.getHealthDataFromTypes(
types: types,
startTime: from,
endTime: now,
);
< /code>
Я уже пробовал следующие шаги, предложенные в других постах: < /strong> < /p>
Добавление всех read_ssee_session, write_session, read_sleep_stage,
write_ssectage permissions in the manifest. FlutterActivity. < /li>
Очистка и восстановление приложения (Flutter Clean → Flutter Pub get →
Flutter Run). < /li>
< /ul>
Подробнее здесь: https://stackoverflow.com/questions/797 ... manifest-x
Мобильная версия