8000 Update example (#168) · flutter-webrtc/callkeep@bc36106 · GitHub
[go: up one dir, main page]

Skip to content

Commit bc36106

Browse files
authored
Update example (#168)
* example: pubspec: Sort. * example: pubspec: Remove unused cupertino_icons. * example: pubspec: Upgrade uuid 3.0.7. * example: pubspec: Add flutter_lints 2.0.1. * example: amalysis_options: Set linter without avoid_print which is used too many times. * example: main: Fix non_constant_identifier_names. * example: main: Fix prefer_interpolation_to_compose_strings. * example: main: Rename _MyAppState to MyAppState. Fix library_private_types_in_public_api. * example: main: Fix use_key_in_widget_constructors. * example: main: Fix prefer_const_constructors. * example: main: Fix use_build_context_synchronously.
1 parent f66bba5 commit bc36106

File tree

4 files changed

+26
-21
lines changed

4 files changed

+26
-21
lines changed

example/analysis_options.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
include: package:flutter_lints/flutter.yaml
2+
3+
linter:
4+
rules:
5+
avoid_print: false

example/lib/main.dart

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Future<dynamic> myBackgroundMessageHandler(Map<String, dynamic> message) {
3333
var uuid = payload['uuid'] as String;
3434
var hasVideo = payload['has_video'] == "true";
3535

36-
final callUUID = uuid ?? Uuid().v4();
36+
final callUUID = uuid ?? const Uuid().v4();
3737
_callKeep.on(CallKeepPerformAnswerCallAction(),
3838
(CallKeepPerformAnswerCallAction event) {
3939
print(
@@ -99,13 +99,15 @@ Future<dynamic> myBackgroundMessageHandler(Map<String, dynamic> message) {
9999
}
100100

101101
void main() {
102-
runApp(MyApp());
102+
runApp(const MyApp());
103103
}
104104

105105
class MyApp extends StatelessWidget {
106+
const MyApp({Key key}) : super(key: key);
107+
106108
@override
107109
Widget build(BuildContext context) {
108-
return MaterialApp(
110+
return const MaterialApp(
109111
title: 'Welcome to Flutter',
110112
debugShowCheckedModeBanner: false,
111113
home: HomePage(),
@@ -114,8 +116,10 @@ class MyApp extends StatelessWidget {
114116
}
115117

116118
class HomePage extends StatefulWidget {
119+
const HomePage({Key key}) : super(key: key);
120+
117121
@override
118-
_MyAppState createState() => _MyAppState();
122+
MyAppState createState() => MyAppState();
119123
}
120124

121125
class Call {
@@ -125,15 +129,15 @@ class Call {
125129
bool muted = false;
126130
}
127131

128-
class _MyAppState extends State<HomePage> {
132+
class MyAppState extends State<HomePage> {
129133
final FlutterCallkeep _callKeep = FlutterCallkeep();
130134
Map<String, Call> calls = {};
131-
String newUUID() => Uuid().v4();
135+
String newUUID() => const Uuid().v4();
132136
final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();
133137

134-
void iOS_Permission() {
138+
void iOSPermission() {
135139
_firebaseMessaging.requestNotificationPermissions(
136-
IosNotificationSettings(sound: true, badge: true, alert: true));
140+
const IosNotificationSettings(sound: true, badge: true, alert: true));
137141
_firebaseMessaging.onIosSettingsRegistered
138142
.listen((IosNotificationSettings settings) {
139143
print('Settings registered: $settings');
@@ -261,7 +265,7 @@ class _MyAppState extends State<HomePage> {
261265
});
262266
print('Display incoming call now');
263267
final bool hasPhoneAccount = await _callKeep.hasPhoneAccount();
264-
if (!hasPhoneAccount) {
268+
if (!hasPhoneAccount && context.mounted) {
265269
await _callKeep.hasDefaultPhoneAccount(context, <String, dynamic>{
266270
'alertTitle': 'Permissions required',
267271
'alertDescription':
@@ -333,7 +337,7 @@ class _MyAppState extends State<HomePage> {
333337
// _firebaseMessaging.requestNotificationPermissions();
334338

335339
_firebaseMessaging.getToken().then((token) {
336-
print('[FCM] token => ' + token);
340+
print('[FCM] token => $token');
337341
});
338342

339343
_firebaseMessaging.configure(
@@ -346,7 +350,7 @@ class _MyAppState extends State<HomePage> {
346350
var callerName = payload['caller_name'] as String;
347351
var uuid = payload['uuid'] as String;
348352
var hasVideo = payload['has_video'] == "true";
349-
final callUUID = uuid ?? Uuid().v4();
353+
final callUUID = uuid ?? const Uuid().v4();
350354
setState(() {
351355
calls[callUUID] = Call(callerId);
352356
});

example/pubspec.yaml

Lines changed: 5 additions & 9 deletions
28BE
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,12 @@ version: 0.1.1
44

55
# The following line prevents the package from being accidentally published to
66
# pub.dev using `pub publish`. This is preferred for private packages.
7-
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
7+
publish_to: "none" # Remove this line if you wish to publish to pub.dev
88

99
environment:
1010
sdk: ">=2.2.2 <3.0.0"
1111

1212
dependencies:
13-
flutter:
14-
sdk: flutter
15-
1613
callkeep:
1714
# When depending on this package from a real application you should use:
1815
# callkeep: ^x.y.z
@@ -21,13 +18,13 @@ dependencies:
2118
# the parent directory to use the current plugin's version.
2219
path: ../
2320

24-
# The following adds the Cupertino Icons font to your application.
25-
# Use with the CupertinoIcons class for iOS style icons.
26-
cupertino_icons: ^1.0.0
27-
uuid: ^2.0.2
2821
firebase_messaging: ^7.0.0
22+
flutter:
23+
sdk: flutter
24+
uuid: ^3.0.7
2925

3026
dev_dependencies:
27+
flutter_lints: ^2.0.1
3128
flutter_test:
3229
sdk: flutter
3330

@@ -36,7 +33,6 @@ dev_dependencies:
3633

3734
# The following section is specific to Flutter.
3835
flutter:
39-
4036
# The following line ensures that the Material Icons font is
4137
# included with your application, so that you can use the icons in
4238
# the material Icons class.

example/test/widget_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import 'package:flutter_test/flutter_test.dart';
1212
void main() {
1313
testWidgets('Verify Platform version', (WidgetTester tester) async {
1414
// Build our app and trigger a frame.
15-
await tester.pumpWidget(MyApp());
15+
await tester.pumpWidget(const MyApp());
1616

1717
// Verify that platform version is retrieved.
1818
expect(

0 commit comments

Comments
 (0)
0