@@ -33,7 +33,7 @@ Future<dynamic> myBackgroundMessageHandler(Map<String, dynamic> message) {
33
33
var uuid = payload['uuid' ] as String ;
34
34
var hasVideo = payload['has_video' ] == "true" ;
35
35
36
- final callUUID = uuid ?? Uuid ().v4 ();
36
+ final callUUID = uuid ?? const Uuid ().v4 ();
37
37
_callKeep.on (CallKeepPerformAnswerCallAction (),
38
38
(CallKeepPerformAnswerCallAction event) {
39
39
print (
@@ -99,13 +99,15 @@ Future<dynamic> myBackgroundMessageHandler(Map<String, dynamic> message) {
99
99
}
100
100
101
101
void main () {
102
- runApp (MyApp ());
102
+ runApp (const MyApp ());
103
103
}
104
104
105
105
class MyApp extends StatelessWidget {
106
+ const MyApp ({Key key}) : super (key: key);
107
+
106
108
@override
107
109
Widget build (BuildContext context) {
108
- return MaterialApp (
110
+ return const MaterialApp (
109
111
title: 'Welcome to Flutter' ,
110
112
debugShowCheckedModeBanner: false ,
111
113
home: HomePage (),
@@ -114,8 +116,10 @@ class MyApp extends StatelessWidget {
114
116
}
115
117
116
118
class HomePage extends StatefulWidget {
119
+ const HomePage ({Key key}) : super (key: key);
120
+
117
121
@override
118
- _MyAppState createState () => _MyAppState ();
122
+ MyAppState createState () => MyAppState ();
119
123
}
120
124
121
125
class Call {
@@ -125,15 +129,15 @@ class Call {
125
129
bool muted = false ;
126
130
}
127
131
128
- class _MyAppState extends State <HomePage > {
132
+ class MyAppState extends State <HomePage > {
129
133
final FlutterCallkeep _callKeep = FlutterCallkeep ();
130
134
Map <String , Call > calls = {};
131
- String newUUID () => Uuid ().v4 ();
135
+ String newUUID () => const Uuid ().v4 ();
132
136
final FirebaseMessaging _firebaseMessaging = FirebaseMessaging ();
133
137
134
- void iOS_Permission () {
138
+ void iOSPermission () {
135
139
_firebaseMessaging.requestNotificationPermissions (
136
- IosNotificationSettings (sound: true , badge: true , alert: true ));
140
+ const IosNotificationSettings (sound: true , badge: true , alert: true ));
137
141
_firebaseMessaging.onIosSettingsRegistered
138
142
.listen ((IosNotificationSettings settings) {
139
143
print ('Settings registered: $settings ' );
@@ -261,7 +265,7 @@ class _MyAppState extends State<HomePage> {
261
265
});
262
266
print ('Display incoming call now' );
263
267
final bool hasPhoneAccount = await _callKeep.hasPhoneAccount ();
264
- if (! hasPhoneAccount) {
268
+ if (! hasPhoneAccount && context.mounted ) {
265
269
await _callKeep.hasDefaultPhoneAccount (context, < String , dynamic > {
266
270
'alertTitle' : 'Permissions required' ,
267
271
'alertDescription' :
@@ -333,7 +337,7 @@ class _MyAppState extends State<HomePage> {
333
337
// _firebaseMessaging.requestNotificationPermissions();
334
338
335
339
_firebaseMessaging.getToken ().then ((token) {
336
- print ('[FCM] token => ' + token);
340
+ print ('[FCM] token => $ token ' );
337
341
});
338
342
339
343
_firebaseMessaging.configure (
@@ -346,7 +350,7 @@ class _MyAppState extends State<HomePage> {
346
350
var callerName = payload['caller_name' ] as String ;
347
351
var uuid = payload['uuid' ] as String ;
348
352
var hasVideo = payload['has_video' ] == "true" ;
349
- final callUUID = uuid ?? Uuid ().v4 ();
353
+ final callUUID = uuid ?? const Uuid ().v4 ();
350
354
setState (() {
351
355
calls[callUUID] = Call (callerId);
352
356
});
0 commit comments