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

share_facebook_callback plugin helps us for sharing contents and photo Uint8List value to Facebook. Flugin has callback waiting sharing status to Facebook.

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:share_facebook_callback/share_facebook_callback.dart';

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

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

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

class _MyAppState extends State<MyApp> {
  final _shareFacebookCallbackPlugin = ShareFacebookCallback();

  String _platformVersion = 'Unknown';
  String _shareFaceStatus = 'Unknow status';
  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    // We also handle the message potentially returning null.
    try {
      platformVersion =
          await _shareFacebookCallbackPlugin.getPlatformVersion() ??
              'Unknown platform version';
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  Future<void> shareFacebook(String url, String msg) async {
    String shareFaceStatus;

    try {
      shareFaceStatus = await _shareFacebookCallbackPlugin.shareFacebook(
            type: ShareType.shareLinksFacebook,
            url: 'https://vtcpay.vn/',
            quote: 'Happy new year',
          ) ??
          'Unknow sharing Facebook Status';
    } catch (e) {
      shareFaceStatus = 'Failed to call shareFacebook';
    }
    if (!mounted) return;
    setState(() {
      _shareFaceStatus = shareFaceStatus;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('ShareFacebook CallBack'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              ElevatedButton(
                onPressed: () {
                  shareFacebook('https://pub.dev/', 'Flutter');
                },
                style: ElevatedButton.styleFrom(shape: const StadiumBorder()),
                child: const Text('Share Facebook'),
              ),
              const SizedBox(
                height: 30,
              ),
              Text('ShareFacebook Status: $_shareFaceStatus\n'),
              Text('Platform Version: $_platformVersion\n'),
            ],
          ),
        ),
      ),
    );
  }
}
1
likes
150
points
121
downloads

Publisher

unverified uploader

Weekly Downloads

share_facebook_callback plugin helps us for sharing contents and photo Uint8List value to Facebook. Flugin has callback waiting sharing status to Facebook.

Repository (GitHub)
View/report issues

Documentation

API reference

License

GPL-3.0 (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on share_facebook_callback

Packages that implement share_facebook_callback