inter_app_communication 1.0.3 copy "inter_app_communication: ^1.0.3" to clipboard
inter_app_communication: ^1.0.3 copied to clipboard

PlatformAndroid

this is a plugin for inter app communication.

example/lib/main.dart

import 'package:flutter/material.dart';

import 'package:inter_app_communication/inter_app_communication.dart';

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

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();

    InterAppCommunication().onDataReceived.listen((event) {
      // print('#' * 10);
      // print('Received event in example: $event');
      if (event is InterAppCommunicationRequestEvent) {
        InterAppCommunication().sendDataToApp(
          InterAppCommunicationResponseEvent(
            packageId: event.senderPackageId!,
            id: event.id,
            data: {
              'response':
                  'Received request successfully from ${event.packageId}',
            },
          ),
        );
      }
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: ElevatedButton(
            onPressed: () async {
              final response = await InterAppCommunication().sendDataToApp(
                InterAppCommunicationRequestEvent(
                  packageId: 'com.example.test_inter_com',
                  data: {
                    'name': 'ImanGhasemiArani',
                  },
                ),
              );
              print(
                  'ghasemiarani.iman.inter_app_communication_example response = $response');
            },
            child: const Text('Send data to other app'),
          ),
        ),
      ),
    );
  }
}
1
likes
140
points
52
downloads

Publisher

unverified uploader

Weekly Downloads

this is a plugin for inter app communication.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface, uuid

More

Packages that depend on inter_app_communication