### Installation rules Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/examples/with_provider/windows/CMakeLists.txt Configures the installation process for the Windows build, including setting the installation prefix, defining directories for data and libraries, and installing the executable, ICU data, Flutter library, bundled plugin libraries, and assets. ```cmake # === Installation === # Support files are copied into place next to the executable, so that it can # run in place. This is done instead of making a separate bundle (as on Linux) # so that building and running from within Visual Studio will work. set(BUILD_BUNDLE_DIR "$") # Make the "install" step default, as it's required to run. set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) if(PLUGIN_BUNDLED_LIBRARIES) install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() # Fully re-copy the assets directory on each build to avoid having stale files # from a previous install. set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) # Install the AOT library on non-Debug builds only. install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" CONFIGURATIONS Profile;Release COMPONENT Runtime) ``` -------------------------------- ### Installation rules Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/examples/with_provider/linux/CMakeLists.txt Configures the installation process, including setting the install prefix, cleaning the build bundle directory, and installing the executable, ICU data, Flutter library, and bundled plugin libraries. ```cmake # === Installation === # By default, "installing" just makes a relocatable bundle in the build # directory. set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) endif() # Start with a clean build bundle directory every time. install(CODE " file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") " COMPONENT Runtime) set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" COMPONENT Runtime) install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) install(FILES "${bundled_library}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endforeach(bundled_library) # Fully re-copy the assets directory on each build to avoid having stale files ``` -------------------------------- ### Installation Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/website/README.md Installs project dependencies using Yarn. ```bash $ yarn ``` -------------------------------- ### Local Development Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/website/README.md Starts a local development server for live previewing changes. ```bash $ yarn start ``` -------------------------------- ### Upgrade Native Dependencies Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/website/docs/migration-guide.md Commands to clean the Flutter project, get dependencies, and update native iOS pods. ```bash flutter clean flutter pub get ``` ```bash cd ios pod update flutter_facebook_auth ``` -------------------------------- ### Complete Facebook Auth Example Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/website/docs/example.md This Dart code demonstrates a full Flutter application integrating Facebook authentication. It includes login, logout, fetching user data, and displaying access tokens and user information. ```dart import 'dart:convert'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_facebook_auth/flutter_facebook_auth.dart'; void main() { runApp(const MyApp()); } String prettyPrint(Map json) { JsonEncoder encoder = const JsonEncoder.withIndent(' '); String pretty = encoder.convert(json); return pretty; } class MyApp extends StatefulWidget { const MyApp({Key? key}) : super(key: key); @override _MyAppState createState() => _MyAppState(); } class _MyAppState extends State { Map? _userData; AccessToken? _accessToken; bool _checking = true; @override void initState() { super.initState(); _checkIfIsLogged(); } Future _checkIfIsLogged() async { final accessToken = await FacebookAuth.instance.accessToken; setState(() { _checking = false; }); if (accessToken != null) { print("is Logged:::: ${prettyPrint(accessToken.toJson())}"); // now you can call to FacebookAuth.instance.getUserData(); final userData = await FacebookAuth.instance.getUserData(); // final userData = await FacebookAuth.instance.getUserData(fields: "email,birthday,friends,gender,link"); _accessToken = accessToken; setState(() { _userData = userData; }); } } void _printCredentials() { print( prettyPrint(_accessToken!.toJson()), ); } Future _login() async { final LoginResult result = await FacebookAuth.instance.login(); // by default we request the email and the public profile // loginBehavior is only supported for Android devices, for ios it will be ignored // final result = await FacebookAuth.instance.login( // permissions: ['email', 'public_profile', 'user_birthday', 'user_friends', 'user_gender', 'user_link'], // loginBehavior: LoginBehavior // .DIALOG_ONLY, // (only android) show an authentication dialog instead of redirecting to facebook app // ); if (result.status == LoginStatus.success) { _accessToken = result.accessToken; _printCredentials(); // get the user data // by default we get the userId, email,name and picture final userData = await FacebookAuth.instance.getUserData(); // final userData = await FacebookAuth.instance.getUserData(fields: "email,birthday,friends,gender,link"); _userData = userData; } else { print(result.status); print(result.message); } setState(() { _checking = false; }); } Future _logOut() async { await FacebookAuth.instance.logOut(); _accessToken = null; _userData = null; setState(() {}); } @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( title: const Text('Facebook Auth Example'), ), body: _checking ? const Center( child: CircularProgressIndicator(), ) : SingleChildScrollView( child: Padding( padding: const EdgeInsets.all(8.0), child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ Text( _userData != null ? prettyPrint(_userData!) : "NO LOGGED", ), const SizedBox(height: 20), _accessToken != null ? Text( prettyPrint(_accessToken!.toJson()), ) : Container(), const SizedBox(height: 20), CupertinoButton( color: Colors.blue, child: Text( _userData != null ? "LOGOUT" : "LOGIN", style: const TextStyle(color: Colors.white), ), onPressed: _userData != null ? _logOut : _login, ), const SizedBox(height: 50), ], ), ), ), ), ); } } ``` -------------------------------- ### Flutter library and application build rules Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/examples/with_provider/windows/CMakeLists.txt Includes the Flutter managed directory and the runner subdirectory for building the application. ```cmake # Flutter library and tool build rules. set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) # Application build; see runner/CMakeLists.txt. add_subdirectory("runner") # Generated plugin build rules, which manage building the plugins and adding # them to the application. include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Project-level configuration Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/examples/with_provider/windows/CMakeLists.txt Sets the minimum CMake version, project name, and executable name for the Windows build. ```cmake cmake_minimum_required(VERSION 3.14) project(flutter_facebook_auth_example LANGUAGES CXX) # The name of the executable created for the application. Change this to change # the on-disk name of your application. set(BINARY_NAME "flutter_facebook_auth_example") # Explicitly opt in to modern CMake behaviors to avoid warnings with recent # versions of CMake. cmake_policy(SET CMP0063 NEW) ``` -------------------------------- ### CMakeLists.txt Configuration Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/examples/with_provider/linux/CMakeLists.txt This snippet shows the CMake configuration for installing Flutter assets and the AOT library on Linux. ```cmake # from a previous install. set(FLUTTER_ASSET_DIR_NAME "flutter_assets") install(CODE " file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") " COMPONENT Runtime) install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) # Install the AOT library on non-Debug builds only. if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" COMPONENT Runtime) endif() ``` -------------------------------- ### Complete AndroidManifest.xml example Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/website/docs/android.md A comprehensive example of the AndroidManifest.xml file including Facebook SDK configurations and activity setup. ```xml ``` -------------------------------- ### Web Entrypoint Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/examples/with_provider/web/index.html This script initializes the Flutter engine and runs the application for the web. ```javascript flutter_facebook_auth_example // The value below is injected by flutter build, do not touch. var serviceWorkerVersion = null; window.addEventListener('load', function(ev) { // Download main.dart.js _flutter.loader.loadEntrypoint({ serviceWorker: { serviceWorkerVersion: serviceWorkerVersion, } }).then(function(engineInitializer) { return engineInitializer.initializeEngine(); }).then(function(appRunner) { return appRunner.runApp(); }); }); ``` -------------------------------- ### Profile build mode settings Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/examples/with_provider/windows/CMakeLists.txt Sets linker and compiler flags for the Profile build mode to match the Release build mode. ```cmake # Define settings for the Profile build mode. set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") ``` -------------------------------- ### Interactive Blog Post Example Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/website/blog/2021-08-01-mdx-blog-post.mdx This code snippet demonstrates how to use React to create interactive blog posts using MDX. ```javascript ``` -------------------------------- ### Build configuration option Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/examples/with_provider/windows/CMakeLists.txt Defines build configuration types (Debug, Profile, Release) based on whether the generator is multi-config. ```cmake # Define build configuration option. get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(IS_MULTICONFIG) set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" CACHE STRING "" FORCE) else() if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Flutter build mode" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Profile" "Release") endif() endif() ``` -------------------------------- ### Initialize Facebook SDK on Web Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/website/docs/web.md Example of how to initialize the Facebook JavaScript SDK within the main function of a Flutter web app. This ensures the SDK is ready before the app starts. ```dart import 'package:flutter/foundation.dart' show kIsWeb; import 'package:flutter_facebook_auth/flutter_facebook_auth.dart'; . . . Future main() async { // check if is running on Web if (kIsWeb) { // initialize the facebook javascript SDK await FacebookAuth.i.webAndDesktopInitialize( appId: "YOUR_FACEBOOK_APP_ID", cookie: true, xfbml: true, version: "v15.0", ); } runApp(MyApp()); } ``` -------------------------------- ### strings.xml example Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/website/docs/android.md An example of strings.xml with actual Facebook App ID and Client Token placeholders. ```xml 1365719610250300 YOUR_CLIENT_TOKEN ``` -------------------------------- ### Standard compilation settings function Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/examples/with_provider/windows/CMakeLists.txt Applies common compilation features and options to a target, including C++17 standard, warning levels, exception handling, and debug definitions. ```cmake # Compilation settings that should be applied to most targets. # # Be cautious about adding new options here, as plugins use this function by # default. In most cases, you should add new options to specific targets instead # of modifying this function. function(APPLY_STANDARD_SETTINGS TARGET) target_compile_features(${TARGET} PUBLIC cxx_std_17) target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") target_compile_options(${TARGET} PRIVATE /EHsc) target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") endfunction() ``` -------------------------------- ### Project-level configuration Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/examples/with_provider/linux/CMakeLists.txt Sets the minimum CMake version, project name, and executable name. It also defines the application ID and opts into modern CMake behaviors. ```cmake cmake_minimum_required(VERSION 3.10) project(runner LANGUAGES CXX) # The name of the executable created for the application. Change this to change # the on-disk name of your application. set(BINARY_NAME "flutter_facebook_auth_example") # The unique GTK application identifier for this application. See: # https://wiki.gnome.org/HowDoI/ChooseApplicationID set(APPLICATION_ID "com.example.flutter_facebook_auth_example") # Explicitly opt in to modern CMake behaviors to avoid warnings with recent # versions of CMake. cmake_policy(SET CMP0063 NEW) # Load bundled libraries from the lib/ directory relative to the binary. set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") # Root filesystem for cross-building. if(FLUTTER_TARGET_PLATFORM_SYSROOT) set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) endif() # Define build configuration options. if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Flutter build mode" FORCE) set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Profile" "Release") endif() ``` -------------------------------- ### Application target definition Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/examples/with_provider/linux/CMakeLists.txt Defines the main application executable, including source files and linking against Flutter and GTK libraries. It also applies standard build settings and dependencies. ```cmake # Flutter library and tool build rules. set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) # System-level dependencies. find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") # Define the application target. To change its name, change BINARY_NAME above, # not the value here, or `flutter run` will no longer work. # # Any new source files that you add to the application should be added here. add_executable(${BINARY_NAME} "main.cc" "my_application.cc" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" ) # Apply the standard set of build settings. This can be removed for applications # that need different build settings. apply_standard_settings(${BINARY_NAME}) # Add dependency libraries. Add any application-specific dependencies here. target_link_libraries(${BINARY_NAME} PRIVATE flutter) target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) # Run the Flutter tool portions of the build. This must not be removed. add_dependencies(${BINARY_NAME} flutter_assemble) # Only the install-generated bundle's copy of the executable will launch # correctly, since the resources must in the right relative locations. To avoid # people trying to run the unbundled copy, put it in a subdirectory instead of # the default top-level location. set_target_properties(${BINARY_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" ) # Generated plugin build rules, which manage building the plugins and adding # them to the application. include(flutter/generated_plugins.cmake) ``` -------------------------------- ### Flutter Library Setup Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/examples/with_provider/windows/flutter/CMakeLists.txt Configures the Flutter library, including setting paths for the DLL, ICU data, project build directory, and AOT library, and defines include directories and dependencies. ```cmake # === Flutter Library === set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") # Published to parent scope for install step. set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) list(APPEND FLUTTER_LIBRARY_HEADERS "flutter_export.h" "flutter_windows.h" "flutter_messenger.h" "flutter_plugin_registrar.h" "flutter_texture_registrar.h" ) list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") add_dependencies(flutter flutter_assemble) ``` -------------------------------- ### Main CMakeLists.txt Configuration Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/examples/with_provider/windows/flutter/CMakeLists.txt This snippet shows the main CMakeLists.txt file for a Flutter Windows project, including minimum CMake version, ephemeral directory setup, and inclusion of generated configuration. ```cmake cmake_minimum_required(VERSION 3.14) set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") # Configuration provided via flutter tool. include(${EPHEMERAL_DIR}/generated_config.cmake) ``` -------------------------------- ### Get User Data Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/website/docs/user-information.md Demonstrates how to call the `getUserData` method to fetch basic user information like email, ID, name, and picture. ```dart final userData = await FacebookAuth.instance.getUserData(); // or FacebookAuth.i.getUserData() ``` -------------------------------- ### Merging Info.plist Entries for Multiple Providers Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/website/docs/ios.md Example of merging Facebook and Google entries in CFBundleURLTypes within Info.plist when implementing multiple authentication providers. ```xml CFBundleURLTypes CFBundleTypeRole Editor CFBundleURLSchemes fb{your-app-id} com.googleusercontent.apps.{your-app-specific-url} ``` -------------------------------- ### Request AppTrackingTransparency and Login Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/website/docs/login.md On iOS 17+, request AppTrackingTransparency permission before initiating the Facebook login. This example uses the permission_handler package. ```dart await Permission.appTrackingTransparency.request(); final LoginResult result = await FacebookAuth.instance.login(); ``` -------------------------------- ### Basic Login Request Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/website/docs/login.md Perform a basic login request to get email and public profile permissions. The login method is asynchronous. ```dart final LoginResult result = await FacebookAuth.instance.login(); // by default we request the email and the public profile // or FacebookAuth.i.login() if (result.status == LoginStatus.success) { // you are logged final AccessToken accessToken = result.accessToken!; } else { print(result.status); print(result.message); } ``` -------------------------------- ### Get Extended User Data Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/website/docs/user-information.md Shows how to request additional user fields such as birthday, friends, gender, and link by specifying them in the `fields` parameter of `getUserData` after logging in with the necessary permissions. ```dart final result = await FacebookAuth.i.login( permissions: ['email', 'public_profile', 'user_birthday', 'user_friends', 'user_gender', 'user_link'], ); if (result.status == LoginStatus.success) { final userData = await FacebookAuth.i.getUserData( fields: "name,email,picture.width(200),birthday,friends,gender,link", ); } ``` -------------------------------- ### Build Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/website/README.md Generates static content for deployment. ```bash $ yarn build ``` -------------------------------- ### Deployment Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/website/README.md Builds the website and deploys it to the gh-pages branch, suitable for GitHub Pages hosting. ```bash $ GIT_USER= USE_SSH=true yarn deploy ``` -------------------------------- ### macOS and Web Main.dart Initialization Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/website/docs/macos.md Initialize the FacebookAuth plugin for both macOS and Web platforms in your main.dart file. ```dart import 'package:flutter/foundation.dart' show defaultTargetPlatform, kIsWeb; void main() async { if (kIsWeb || defaultTargetPlatform == TargetPlatform.macOS) { await FacebookAuth.i.webAndDesktopInitialize( appId: "YOUR_APP_ID", cookie: true, xfbml: true, version: "v14.0", ); } runApp(MyApp()); } ``` -------------------------------- ### macOS Main.dart Initialization Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/website/docs/macos.md Initialize the FacebookAuth plugin for macOS in your main.dart file, checking the platform. ```dart import 'package:flutter/foundation.dart' show defaultTargetPlatform; void main() async { if (defaultTargetPlatform == TargetPlatform.macOS) { await FacebookAuth.i.webAndDesktopInitialize( appId: "1329834907365798", cookie: true, xfbml: true, version: "v14.0", ); } runApp(MyApp()); } ``` -------------------------------- ### macOS Info.plist Configuration Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/website/docs/macos.md Add the 'com.apple.security.network.server' key to your macos/runner/info.plist file to allow network server access. ```xml com.apple.security.network.server ``` -------------------------------- ### C++ Wrapper Library for Plugins Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/examples/with_provider/windows/flutter/CMakeLists.txt Defines a static library for the C++ wrapper used by plugins, including core and plugin-specific sources, and sets up target properties and include directories. ```cmake # === Wrapper === list(APPEND CPP_WRAPPER_SOURCES_CORE "core_implementations.cc" "standard_codec.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") list(APPEND CPP_WRAPPER_SOURCES_PLUGIN "plugin_registrar.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") list(APPEND CPP_WRAPPER_SOURCES_APP "flutter_engine.cc" "flutter_view_controller.cc" ) list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") # Wrapper sources needed for a plugin. add_library(flutter_wrapper_plugin STATIC ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ) apply_standard_settings(flutter_wrapper_plugin) set_target_properties(flutter_wrapper_plugin PROPERTIES POSITION_INDEPENDENT_CODE ON) set_target_properties(flutter_wrapper_plugin PROPERTIES CXX_VISIBILITY_PRESET hidden) target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) target_include_directories(flutter_wrapper_plugin PUBLIC "${WRAPPER_ROOT}/include" ) add_dependencies(flutter_wrapper_plugin flutter_assemble) ``` -------------------------------- ### Flutter Tool Backend Command Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/examples/with_provider/windows/flutter/CMakeLists.txt Configures a custom command to run the Flutter tool backend, which is essential for generating build artifacts. It uses a phony output to ensure execution on every build. ```cmake # === Flutter tool backend === # _phony_ is a non-existent file to force this command to run every time, # since currently there's no way to get a full input/output list from the # flutter tool. set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) add_custom_command( OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ${PHONY_OUTPUT} COMMAND ${CMAKE_COMMAND} -E env ${FLUTTER_TOOL_ENVIRONMENT} "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" windows-x64 $ VERBATIM ) add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} ${CPP_WRAPPER_SOURCES_APP} ) ``` -------------------------------- ### Windows Runner CMakeLists.txt Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/examples/with_provider/windows/runner/CMakeLists.txt The CMakeLists.txt file for the Windows runner application, defining build targets, dependencies, and compiler settings. ```cmake cmake_minimum_required(VERSION 3.14) project(runner LANGUAGES CXX) # Define the application target. To change its name, change BINARY_NAME in the # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer # work. # # Any new source files that you add to the application should be added here. add_executable(${BINARY_NAME} WIN32 "flutter_window.cpp" "main.cpp" "utils.cpp" "win32_window.cpp" "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" "Runner.rc" "runner.exe.manifest" ) # Apply the standard set of build settings. This can be removed for applications # that need different build settings. apply_standard_settings(${BINARY_NAME}) # Disable Windows macros that collide with C++ standard library functions. target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") # Add dependency libraries and include directories. Add any application-specific # dependencies here. target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") # Run the Flutter tool portions of the build. This must not be removed. add_dependencies(${BINARY_NAME} flutter_assemble) ``` -------------------------------- ### C++ Wrapper Library for Runner Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/examples/with_provider/windows/flutter/CMakeLists.txt Defines a static library for the C++ wrapper used by the application runner, including core and app-specific sources, and sets up target properties and include directories. ```cmake # Wrapper sources needed for the runner. add_library(flutter_wrapper_app STATIC ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_APP} ) apply_standard_settings(flutter_wrapper_app) target_link_libraries(flutter_wrapper_app PUBLIC flutter) target_include_directories(flutter_wrapper_app PUBLIC "${WRAPPER_ROOT}/include" ) add_dependencies(flutter_wrapper_app flutter_assemble) ``` -------------------------------- ### Add to pubspec.yaml Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/website/docs/intro.md Add the flutter_facebook_auth dependency to your pubspec.yaml file. ```yaml dependencies: flutter_facebook_auth: ^7.1.4 ``` -------------------------------- ### Podfile Minimum iOS Version Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/website/docs/ios.md Uncomment and set the minimum iOS platform version to 12.0 or higher in your Podfile. ```ruby platform :ios, '12.0' ``` -------------------------------- ### Import the Plugin Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/website/docs/login.md Import the flutter_facebook_auth plugin to access its functionalities. ```dart import 'package:flutter_facebook_auth/flutter_facebook_auth.dart'; ``` -------------------------------- ### CMakeLists.txt Configuration Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/examples/with_provider/linux/flutter/CMakeLists.txt The main CMakeLists.txt file for the Flutter Linux GTK project, controlling build steps and dependencies. ```cmake cmake_minimum_required(VERSION 3.10) set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") # Configuration provided via flutter tool. include(${EPHEMERAL_DIR}/generated_config.cmake) # TODO: Move the rest of this into files in ephemeral. See # https://github.com/flutter/flutter/issues/57146. # Serves the same purpose as list(TRANSFORM ... PREPEND ...), # which isn't available in 3.10. function(list_prepend LIST_NAME PREFIX) set(NEW_LIST "") foreach(element ${${LIST_NAME}}) list(APPEND NEW_LIST "${PREFIX}${element}") endforeach(element) set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) endfunction() # === Flutter Library === # System-level dependencies. find_package(PkgConfig REQUIRED) pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") # Published to parent scope for install step. set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) list(APPEND FLUTTER_LIBRARY_HEADERS "fl_basic_message_channel.h" "fl_binary_codec.h" "fl_binary_messenger.h" "fl_dart_project.h" "fl_engine.h" "fl_json_message_codec.h" "fl_json_method_codec.h" "fl_message_codec.h" "fl_method_call.h" "fl_method_channel.h" "fl_method_codec.h" "fl_method_response.h" "fl_plugin_registrar.h" "fl_plugin_registry.h" "fl_standard_message_codec.h" "fl_standard_method_codec.h" "fl_string_codec.h" "fl_value.h" "fl_view.h" "flutter_linux.h" ) list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") add_library(flutter INTERFACE) target_include_directories(flutter INTERFACE "${EPHEMERAL_DIR}" ) target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") target_link_libraries(flutter INTERFACE PkgConfig::GTK PkgConfig::GLIB PkgConfig::GIO ) add_dependencies(flutter flutter_assemble) # === Flutter tool backend === # _phony_ is a non-existent file to force this command to run every time, # since currently there's no way to get a full input/output list from the # flutter tool. add_custom_command( OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/_phony_ COMMAND ${CMAKE_COMMAND} -E env ${FLUTTER_TOOL_ENVIRONMENT} "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} VERBATIM ) add_custom_target(flutter_assemble DEPENDS "${FLUTTER_LIBRARY}" ${FLUTTER_LIBRARY_HEADERS} ) ``` -------------------------------- ### Dart SDK version requirement Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/website/docs/intro.md Ensure your project uses Dart 3.x or higher for versions 6.x and above. ```yaml environment: sdk: ">=3.4.0 <4.0.0" ``` -------------------------------- ### Info.plist Configuration for Facebook Login Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/website/docs/ios.md Add these keys to your Info.plist file to configure Facebook App ID, Display Name, Client Token, and URL Schemes. Replace placeholders with your actual app details. ```xml CFBundleURLTypes CFBundleURLSchemes fb{your-app-id} FacebookAppID {your-app-id} FacebookClientToken CLIENT-TOKEN FacebookDisplayName {your-app-name} LSApplicationQueriesSchemes fbapi fb-messenger-share-api ``` -------------------------------- ### AppDelegate.swift - Application Open URL Override Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/website/docs/ios.md A warning to check if the application(_:open:options:) function in AppDelegate.swift is being overridden, which might interfere with login callbacks. ```swift override func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool { ... } ``` -------------------------------- ### Update minSdkVersion in build.gradle Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/website/docs/android.md Ensures the minimum Android SDK version is compatible with the Facebook SDK. ```gradle defaultConfig { ... minSdkVersion 21 targetSdkVersion 33 ... } ``` -------------------------------- ### strings.xml configuration Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/website/docs/android.md Defines the Facebook App ID and Client Token in the Android resources. ```xml {your-app-id} YOUR_CLIENT_TOKEN ``` -------------------------------- ### Package Visibility Declaration Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/website/docs/android.md Declare package visibility needs for apps targeting Android API 30+ to allow calls to Facebook native apps. ```xml ... ``` -------------------------------- ### Firebase Auth with Facebook Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/website/docs/firebase-auth.md This code snippet shows how to sign in a user with Firebase Authentication after they have successfully logged in with Facebook using flutter_facebook_auth. ```dart import 'package:firebase_auth/firebase_auth.dart'; . . . Future signInWithFacebook() async { final LoginResult result = await FacebookAuth.instance.login(); if(result.status == LoginStatus.success){ // Create a credential from the access token final OAuthCredential credential = FacebookAuthProvider.credential(result.accessToken!.tokenString); // Once signed in, return the UserCredential return await FirebaseAuth.instance.signInWithCredential(credential); } return null; } ``` -------------------------------- ### Login with Specific Permissions Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/website/docs/login.md Request specific permissions by passing a list of permissions to the login method. ```dart final LoginResult result = await FacebookAuth.instance.login( permissions: ['public_profile', 'email', 'pages_show_list', 'pages_messaging', 'pages_manage_metadata'], ); // or // FacebookAuth.i.login( // permissions: ['public_profile', 'email', 'pages_show_list', 'pages_messaging', 'pages_manage_metadata'], // ) ``` -------------------------------- ### AndroidManifest.xml permissions and metadata Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/website/docs/android.md Adds necessary internet permission and Facebook SDK metadata to the Android Manifest. ```xml ``` -------------------------------- ### Opt out of Advertising ID Permission Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/website/docs/android.md Add a uses-permission element to opt out of the Advertising ID Permission. ```xml ``` -------------------------------- ### Log Out Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/website/docs/login.md Log the user out by calling the `logOut` method. ```dart await FacebookAuth.instance.logOut(); // or FacebookAuth.i.logOut(); ``` -------------------------------- ### Check if User is Logged In Source: https://github.com/darwin-morocho/flutter-facebook-auth/blob/master/website/docs/login.md Check if the user is currently logged in by accessing the `accessToken` property. ```dart final AccessToken? accessToken = await FacebookAuth.instance.accessToken; // or FacebookAuth.i.accessToken if (accessToken != null) { // user is logged } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.