ABOUT YOU Dart & Flutter Packages
repository·master·Indexed 42 days ago
https://github.com/aboutyou/dart_packagesA collection of Dart and Flutter plugins maintained by ABOUT YOU, featuring state management, authentication, and operation queuing. Key packages include sign_in_with_apple (supporting iOS, macOS, Android, and Web), pending_operations, state_queue, and with_bloc.
What's inside ABOUT YOU Dart Packages
- This repository contains a collection of Dart and Flutter plugins maintained and used by ABOUT YOU. These packages include utilities for state management, authentication, and operation handling.
Overview of sign_in_with_apple_platform_interface
masterThesign_in_with_apple_platform_interfacepackage provides a common platform interface for thesign_in_with_appleplugin. It is designed to ensure that both the main plugin and its various platform-specific implementations (such as iOS or Android) adhere to the same API contract, enabling consistent behavior across different platforms.Overview of the pending_operations package
masterThepending_operationspackage is a Dart/Flutter library module designed to contain code that can be shared across multiple Flutter or Dart projects. It serves as a foundational starting point for developing reusable package logic within the Flutter ecosystem.Sign in With Apple overview
masterThesign_in_with_applepackage provides a Flutter bridge for implementing 'Sign in with Apple'. It allows users to log in using their Apple ID and enables the retrieval of credentials stored in the user's keychain.Use Sign in with Apple for Flutter Web
masterThesign_in_with_apple_webpackage provides Flutter web support for thesign_in_with_appleplugin. It allows developers to implement 'Sign in with Apple' functionality within web applications built with Flutter.Understand the Sign in with Apple integration flow
masterIntegrating Sign in with Apple requires a full-stack approach. The plugin handles the client-side interaction, but you must implement server-side verification to ensure security.
The complete flow is:
- Client-side: The Flutter app uses the plugin to request credentials from Apple.
- Credential Receipt: The plugin receives credentials (like an authorization
code). - Server-side Verification: Your backend must send these credentials to Apple's servers to verify they are valid and belong to the intended user.
- Session Management: Once verified, your server derives a new session for the user. Your server should use a refresh token to verify the session with Apple daily and revoke the session if the user withdraws authorization on Apple's side.
Configure local domain and Redirect URL for Sign in with Apple
masterTo test the web plugin locally, you must use a valid domain that is registered with your Sign in with Apple service in the Apple Developer portal.
- Local Mapping: Add the domain to your
/etc/hostsfile (e.g.,127.0.0.1 siwa-flutter-plugin.dev). - Apple Portal: Register this domain as both a
Domainand aRedirect URLin the development portal. - Glitch Example: If using the Glitch example server, ensure the redirect URL parameter is set to your local HTTPS domain (e.g.,
https://siwa-flutter-plugin.dev/).
- Local Mapping: Add the domain to your
Configure Web support for Sign in with Apple
masterScript Import
Add this script to the
<head>tag of yourindex.html:<script type="text/javascript" src="https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js"></script>Apple Developer Portal Configuration
In your Service ID settings:
- Domains and Subdomains: Add the domain hosting your web app.
- Return URLs: Add the URL where Apple will post the final credentials. If this is omitted, the authentication flow will hang at the last step.
Test Android deep links for sign_in_with_apple
masterYou can test Android deep link handling using
adb. This is useful for simulating the callback from the Sign In with Apple (SiwA) process or testing general deep link navigation within the app.Simulate a SiwA callback
Use this command to mimic the
intent://link that a successful redirect would use:adb shell am start -a android.intent.action.VIEW \ -c android.intent.category.BROWSABLE \ -d "signinwithapple://callback?code=abc123" com.aboutyou.dart_packages.sign_in_with_apple_exampleSimulate a general deep link
Use this command to test deep link entry into the app. Note that this will close the Chrome Custom Tab if a SiwA login flow is currently active:
adb shell am start -a android.intent.action.VIEW \ -c android.intent.category.BROWSABLE \ -d "siwa-example://siwa.example.com/foo" com.aboutyou.dart_packages.sign_in_with_apple_exampleConfigure Android support for Sign in with Apple
masterRequirements
- Android V2 Embedding: Ensure your project uses the Android V2 embedding by checking
AndroidManifest.xmlfor:<meta-data android:name="flutterEmbedding" android:value="2" /> - Launch Mode: To ensure deep links from the Chrome Custom Tab return to your app, set your
launchModeto eithersingleTaskorsingleTopin your Android configuration.
Android Manifest Setup
Add the following activity to your
android/app/src/main/AndroidManifest.xmlinside the<application>tag to handle the callback:<activity android:name="com.aboutyou.dart_packages.sign_in_with_apple.SignInWithAppleCallback" android:exported="true" > <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="signinwithapple" /> <data android:path="callback" /> </intent-filter> </activity>Redirecting back to Android
On your server, after processing the Apple callback, redirect the user back to your app using this intent URL format:
intent://callback?${PARAMETERS_FROM_CALLBACK_BODY}#Intent;package=YOUR.PACKAGE.IDENTIFIER;scheme=signinwithapple;end- Replace
${PARAMETERS_FROM_CALLBACK_BODY}with the urlencoded body received from Apple. - Replace
YOUR.PACKAGE.IDENTIFIERwith your app's Play Store package ID.
- Android V2 Embedding: Ensure your project uses the Android V2 embedding by checking
Run tests for WithBloc
masterTo execute the test suite for the
with_blocpackage, use the standard Flutter test command in your terminal.flutter testSet up sign_in_with_apple on macOS
masterTo run the example on macOS, ensure you have
cocoapodsinstalled globally (Flutter requires a global installation to gather plugin information). You must also enable macOS desktop support in your Flutter configuration.- Install CocoaPods via Homebrew if not already present.
- Enable macOS desktop support.
- Run the application on the macOS desktop target.
brew install cocoapods flutter config --enable-macos-desktop flutter run -d macOS