Skip to main content

FedID Flutter package

Utilizing the Flutter package for FedID involves the same steps as using any other package. First, add FedID to your Flutter project:

# Post-release, FedID will be available in the Flutter repository
flutter pub add fedid

# Until then you can clone the repo at https://codeberg.org/fedid/flutter-library
# and include it in ypur `pubspec.yaml`:
#
# dependencies:
# ...
# fedid:
# path: ../library-flutter/src
# ...

After spinning up your FedID server, you will next need to tell your app to use the FedID Server:

# Import the package
import 'package:fedid/package.dart';

# Set your resolver URL
setFedIdResolverUrl('https://fedid.domain.ext', context);

Android

To enable FedID logins, you will need to enable support for custom URLs by adding this to your AndroidManifest.xml, inside the activity block:

<meta-data android:name="flutter_deeplinking_enabled" android:value="false" />
<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="fedid" android:host="fedid.me" android:pathPrefix="/fedid-login" />
</intent-filter>

You will also need to ensure the following permissions exist for internet access and the ability to read recovery keys from storage:

    <uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />

Lastly, for compatibility with older phones, in the application block, add:

    <application>
...
android:requestLegacyExternalStorage="true"
...
</application>

iOS

For iOS, permission details must be included for using the camera to scan QR codes. These should be added to Info.plist:

<key>NSCameraUsageDescription</key>
<string>This app needs camera access to scan QR codes</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>This app needs photos access to get QR code from photo library</string>

Routes

There are two routes you can use to direct users to the screens built into the package:

RouteDescription
/fedid-accountsAdd/edit/remove accounts from the device
/fedid-loginLogin to services using a FedID Account

These can be used at any point with the standard Navigator or any custom navigation:

onPressed: () {
Navigator.restorablePushNamed(
context,
'/fedid-accounts',
);
},