my code ->
import 'package:app_usage/app_usage.dart';
class ScreenTimeService {
Future<List<AppUsageInfo>> getUsageStats() async {
try {
DateTime endDate = DateTime.now();
DateTime startDate = endDate.subtract(const Duration(days: 1));
List<AppUsageInfo> infoList = await AppUsage().getAppUsage(startDate, endDate);
infoList.removeWhere((app) => app.usage.inSeconds == 0);
return infoList;
} on AppUsageException catch (exception) {
print(exception);
// You should guide the user to the settings here
// AppUsage().openUsageSettings();
return [];
}
}
}
The full codebase it logically and syntax correct but I'm getting this error
The name 'AppUsageException' isn't a type and can't be used in an on-catch clause. Try correcting the name to match an existing class.