call_log_new
A Flutter Plugin for Accessing Call Logs
The call_log_new plugin provides access to the call logs on Android devices, allowing you to fetch details such as phone numbers, call types, call dates, and durations.
Features
Fetch call logs from the device Retrieve details like phone numbers, call types, dates, and durations
Getting Started
Installation To use the call_log_new plugin in your Flutter project, add it as a dependency in your pubspec.yaml:
dependencies:
_call_log_new: ^1.0.0 # Replace with the latest version
Run flutter pub get to install the plugin.
Usage Fetching Call Logs
import 'package:_call_log_new/_call_log_new.dart';
void fetchCallLogs() async {
try {
final logs = await CallLog.fetchCallLogs();
// Use the fetched call logs
print(logs);
} catch (e) {
print("Error fetching call logs: $e");
}
}
Handling Permissions
The plugin requires permissions to access call logs. Ensure you handle the necessary permissions in your app:
import 'package:permission_handler/permission_handler.dart';
void requestPermissions() async {
if (await Permission.phone.request().isGranted &&
await Permission.contacts.request().isGranted) {
fetchCallLogs();
} else {
print("Permissions denied");
}
}
Android Setup
Ensure that your AndroidManifest.xml includes the necessary permissions:
Contribution
Contributions are welcome! Feel free to open issues or submit pull requests.