8000 Update example by ryojiro · Pull Request #168 · flutter-webrtc/callkeep · GitHub
[go: up one dir, main page]

Skip to content

Update example #168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Apr 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include: package:flutter_lints/flutter.yaml

linter:
rules:
avoid_print: false
26 changes: 15 additions & 11 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Future<dynamic> myBackgroundMessageHandler(Map<String, dynamic> message) {
var uuid = payload['uuid'] as String;
var hasVideo = payload['has_video'] == "true";

final callUUID = uuid ?? Uuid().v4();
final callUUID = uuid ?? const Uuid().v4();
_callKeep.on(CallKeepPerformAnswerCallAction(),
(CallKeepPerformAnswerCallAction event) {
print(
Expand Down Expand Up @@ -99,13 +99,15 @@ Future<dynamic> myBackgroundMessageHandler(Map<String, dynamic> message) {
}

void main() {
runApp(MyApp());
runApp(const MyApp());
}

class MyApp extends StatelessWidget {
const MyApp({Key key}) : super(key: key);

@override
Widget build(BuildContext context) {
return MaterialApp(
return const MaterialApp(
title: 'Welcome to Flutter',
debugShowCheckedModeBanner: false,
home: HomePage(),
Expand All @@ -114,8 +116,10 @@ class MyApp extends StatelessWidget {
}

class HomePage extends StatefulWidget {
const HomePage({Key key}) : super(key: key);

@override
_MyAppState createState() => _MyAppState();
MyAppState createState() => MyAppState();
}

class Call {
Expand All @@ -125,15 +129,15 @@ class Call {
bool muted = false;
}

class _MyAppState extends State<HomePage> {
class MyAppState extends State<HomePage> {
final FlutterCallkeep _callKeep = FlutterCallkeep();
Map<String, Call> calls = {};
String newUUID() => Uuid().v4();
String newUUID() => const Uuid().v4();
final FirebaseMessaging _firebaseMessaging = FirebaseMessaging();

void iOS_Permission() {
void iOSPermission() {
_firebaseMessaging.requestNotificationPermissions(
IosNotificationSettings(sound: true, badge: true, alert: true));
const IosNotificationSettings(sound: true, badge: true, alert: true));
_firebaseMessaging.onIosSettingsRegistered
.listen((IosNotificationSettings settings) {
print('Settings registered: $settings');
Expand Down Expand Up @@ -261,7 +265,7 @@ class _MyAppState extends State<HomePage> {
});
print('Display incoming call now');
final bool hasPhoneAccount = await _callKeep.hasPhoneAccount();
if (!hasPhoneAccount) {
if (!hasPhoneAccount && context.mounted) {
await _callKeep.hasDefaultPhoneAccount(context, <String, dynamic>{
'alertTitle': 'Permissions required',
'alertDescription':
Expand Down Expand Up @@ -333,7 +337,7 @@ class _MyAppState extends State<HomePage> {
// _firebaseMessaging.requestNotificationPermissions();

_firebaseMessaging.getToken().then((token) {
print('[FCM] token => ' + token);
print('[FCM] token => $token');
});

_firebaseMessaging.configure(
Expand All @@ -346,7 +350,7 @@ class _MyAppState extends State<HomePage> {
var callerName = payload['caller_name'] as String;
var uuid = payload['uuid'] as String;
var hasVideo = payload['has_video'] == "true";
final callUUID = uuid ?? Uuid().v4();
final callUUID = uuid ?? const Uuid().v4();
setState(() {
calls[callUUID] = Call(callerId);
});
Expand Down
14 changes: 5 additions & 9 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@ version: 0.1.1

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

environment:
sdk: ">=2.2.2 <3.0.0"

dependencies:
flutter:
sdk: flutter

callkeep:
# When depending on this package from a real application you should use:
# callkeep: ^x.y.z
Expand All @@ -21,13 +18,13 @@ dependencies:
# the parent directory to use the current plugin's version.
path: ../

# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.0
uuid: ^2.0.2
firebase_messaging: ^7.0.0
flutter:
sdk: flutter
uuid: ^3.0.7

dev_dependencies:
flutter_lints: ^2.0.1
flutter_test:
sdk: flutter

Expand All @@ -36,7 +33,6 @@ dev_dependencies:

# The following section is specific to Flutter.
flutter:

# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
Expand Down
2 changes: 1 addition & 1 deletion example/test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Verify Platform version', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
await tester.pumpWidget(const MyApp());

// Verify that platform version is retrieved.
expect(
Expand Down
0