flutter_facebook_plugin 0.0.3 copy "flutter_facebook_plugin: ^0.0.3" to clipboard
flutter_facebook_plugin: ^0.0.3 copied to clipboard

outdated

Flutter Facebook to Log in and Sharing dialogs

example/lib/main.dart

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

import 'package:flutter/services.dart';
import 'package:flutter_facebook_plugin/flutter_facebook_plugin.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> {
  String _facebookUserId = 'Unknown';

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Facebook Login and Share Plugin'),
        ),
        body: Column(
          children: [
            Center(
              child: GestureDetector(
                child: const Text("Log in Facebook"),
                onTap: () {
                  initFacebookLoginShare();
                },
              ),
            ),
            Text("Facebook User Id: $_facebookUserId"),
          ],
        ),
      ),
    );
  }

  ///Call the Facebook to Login and Sharing
  Future<void> initFacebookLoginShare() async {
    String? facebookUserId = '';
    try {
      facebookUserId = await FlutterFacebookPlugin.facebookLogin(
          "https://developers.facebook.com");
    } on PlatformException {
      facebookUserId = '';
    }

    setState(() {
      _facebookUserId = facebookUserId!;
    });
  }
}
1
likes
0
points
29
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter Facebook to Log in and Sharing dialogs

Homepage

License

unknown (license)

Dependencies

flutter, flutter_web_plugins

More

Packages that depend on flutter_facebook_plugin