receive_sharing_intent 0.9.0 copy "receive_sharing_intent: ^0.9.0" to clipboard
receive_sharing_intent: ^0.9.0 copied to clipboard

outdated

A flutter plugin that enables flutter apps to receive sharing photos from other apps.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:receive_sharing_intent/receive_sharing_intent.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  StreamSubscription _intentDataStreamSubscription;
  List<Uri> _sharedFiles;

  @override
  void initState() {
    super.initState();

    // For sharing images coming from outside the app while the app is in the memory
    _intentDataStreamSubscription =
        ReceiveSharingIntent.getIntentDataStreamAsUri().listen(
            (List<Uri> uris) {
      setState(() {
        _sharedFiles = uris;
      });
    }, onError: (err) {
      print("Latest Intent Data error: $err");
    });

    // For sharing images coming from outside the app while the app is closed
    ReceiveSharingIntent.getInitialIntentDataAsUri().then((List<Uri> uris) {
      setState(() {
        _sharedFiles = uris;
      });
    });
  }

  @override
  void dispose() {
    _intentDataStreamSubscription.cancel();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Text('Number of shared files: ${_sharedFiles?.length ?? 0}'),
        ),
      ),
    );
  }
}
648
likes
0
pub points
98%
popularity

Publisher

verified publisherkasem.dev

A flutter plugin that enables flutter apps to receive sharing photos from other apps.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on receive_sharing_intent