I faced me many problems with this package in my project, so I created new project and very time when running the app new problem appears
First Time
not aske me for PERMISSIONS and not get any data
Second Time
debug console print
D/flutter/CALL_LOG(22934): onMethodCall
E/flutter (22934): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: PlatformException(MISSING_PERMISSIONS, Permission READ_CALL_LOG or READ_PHONE_STATE is required for plugin. Hovewer, plugin is unable to request permission because of background execution., null, null)
E/flutter (22934): #0 StandardMethodCodec.decodeEnvelope
package:flutter/…/services/message_codecs.dart:597
E/flutter (22934): #1 MethodChannel._invokeMethod
package:flutter/…/services/platform_channel.dart:158
E/flutter (22934):
E/flutter (22934): #2 CallLog.get
package:call_log/call_log.dart:12
E/flutter (22934):
E/flutter (22934): #3 _MyAppState.build.
package:crmapp/main.dart:53
E/flutter (22934):
E/flutter (22934):
Third time
debug console print
D/flutter/CALL_LOG(22934): onMethodCall
E/flutter (22934): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: PlatformException(ALREADY_RUNNING, Method call was cancelled. One method call is already running, null, null)
E/flutter (22934): #0 StandardMethodCodec.decodeEnvelope
package:flutter/…/services/message_codecs.dart:597
E/flutter (22934): #1 MethodChannel._invokeMethod
package:flutter/…/services/platform_channel.dart:158
E/flutter (22934):
E/flutter (22934): #2 CallLog.get
package:call_log/call_log.dart:12
E/flutter (22934):
E/flutter (22934): #3 _MyAppState.build.
package:crmapp/main.dart:53
E/flutter (22934):
E/flutter (22934):
E/MethodChannel#sk.fourq.call_log(22934): Failed to handle method call
E/MethodChannel#sk.fourq.call_log(22934): java.lang.IllegalStateException: Reply already submitted
E/MethodChannel#sk.fourq.call_log(22934): at io.flutter.embedding.engine.dart.DartMessenger$Reply.reply(DartMessenger.java:155)
E/MethodChannel#sk.fourq.call_log(22934): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.error(MethodChannel.java:243)
My Code
`import 'package:call_log/call_log.dart';
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@OverRide
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State {
Iterable _callLogEntries = [];
@OverRide
Widget build(BuildContext context) {
const TextStyle mono = TextStyle(fontSize: 20);
final List children = [];
for (CallLogEntry entry in _callLogEntries) {
children.add(
Column(
children: [
const Divider(),
Text('F. NUMBER : ${entry.formattedNumber}', style: mono),
Text('C.M. NUMBER: ${entry.cachedMatchedNumber}', style: mono),
Text('NUMBER : ${entry.number}', style: mono),
Text('NAME : ${entry.name}', style: mono),
Text('TYPE : ${entry.callType}', style: mono),
// Text('DATE : ${DateTime.fromMillisecondsSinceEpoch(entry.timestamp)}',
// style: mono),
Text('DURATION : ${entry.duration}', style: mono),
Text('ACCOUNT ID : ${entry.phoneAccountId}', style: mono),
Text('SIM NAME : ${entry.simDisplayName}', style: mono),
],
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
),
);
}
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('call_log example')),
body: SingleChildScrollView(
child: Column(
children: <Widget>[
Center(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: ElevatedButton(
onPressed: () async {
final Iterable<CallLogEntry> result = await CallLog.query();
setState(() {
_callLogEntries = result;
});
},
child: const Text('Get all'),
),
),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: Column(children: children),
),
],
),
),
),
);
}
}`
AndroidManifest.xml
<application
**Flutter doctor **
C:\Users\ENG_Ahmed>flutter doctor -v
[√] Flutter (Channel stable, 2.2.1, on Microsoft Windows [Version 10.0.19042.1348], locale en-US)
• Flutter version 2.2.1 at C:\src\flutter
• Framework revision 02c026b03c (6 months ago), 2021-05-27 12:24:44 -0700
• Engine revision 0fdb562ac8
• Dart version 2.13.1
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at C:\Users\ENG_Ahmed\AppData\Local\Android\sdk
• Platform android-30, build-tools 30.0.3
• ANDROID_HOME = C:\Users\ENG_Ahmed\AppData\Local\Android\sdk
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
[√] Android Studio (version 4.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 49.0.2
• Dart plugin version 193.7547
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[√] VS Code (version 1.62.3)
• VS Code at C:\Users\ENG_Ahmed\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.28.0
[√] Connected device (3 available)
• CPH1803 (mobile) • 192.168.1.202:5555 • android-arm64 • Android 8.1.0 (API 27)
• Chrome (web) • chrome • web-javascript • Google Chrome 96.0.4664.45
• Edge (web) • edge • web-javascript • Microsoft Edge 95.0.1020.53
• No issues found!