Infrastructure SDKs
How to read device and app info in a Flutter app
Free Reference for utilities_sdk: every variable, option and package it generates. Command: archipelago generate utilities_sdk
Generate the Utilities SDK, understand its API/Impl pairs under utilities/, read device and package info from synchronous getters, and see what moved out.
What you'll learn
- Generating the Utilities SDK with device info and package info
- Understanding the API/Impl pairs under
utilities/ - Reading device and app information from synchronous getters
- Knowing what moved out of this brick
Prerequisites
- An existing Archipelago monorepo (see Monorepo Scaffolding)
The brick needs archipelago.yaml in the project. With includePackageInfo on, it generates package_info_provider for you if it is missing.
Step 1: Generate the Utilities SDK
archipelago generate utilities_sdkThe prompts are:
- appName: your app name
- organization: your company name
- domain: the top-level domain, such as
com - prefix: a unique prefix, which is required
- includeDeviceInfo: device information (default
true) - includePackageInfo: app version and build information (default
true) - isForMonorepo: leave this as
true - includeGenerated:
falsekeeps generated files out of git
Or use a config file:
{
"appName": "MyApp",
"organization": "MyCompany",
"domain": "com",
"prefix": "App",
"includeDeviceInfo": true,
"includePackageInfo": true,
"isForMonorepo": true,
"includeGenerated": false
}archipelago generate utilities_sdk --config utilities_config.jsonThere is no biometric option. Biometrics live in biometric_auth_sdk.
Step 2: Understand the Generated Structure
Each utility is an API/Impl pair under shared/utilities/ in a monorepo:
shared/utilities/
├── device_info/
│ ├── device_info_api/ # DeviceInfo, DeviceInfoService, DevicePlatform
│ └── device_info_impl/ # DeviceInfoImpl, DI module
└── package_info/
├── package_info_api/ # PackageInfoUtil, InstallerSource
└── package_info_impl/ # PackageInfoImpl, DI moduleOnly the packages you enabled are generated.
Step 3: Check the Registration
The hook adds the impl packages to the app pubspec.yaml and registers DeviceInfoImplPackageModule and PackageInfoImplPackageModule in lib/di/injector.dart. You write no registration code.
Step 4: Use Device Info
The service has a synchronous info getter. DI resolves it once at boot. Take it by constructor:
final info = deviceInfoService.info;
info.platform; // DevicePlatform: ios, android, web, macOS, ...
info.osVersion;
info.manufacturer;
info.model;
info.deviceId;
info.isPhysicalDevice;
info.isLowRamDevice;
info.androidSdkInt;There is no advertising ID. A real one needs its own consent and tracking flow. Use an attribution SDK such as AppsFlyer through analytics_sdk.
Step 5: Use Package Info
packageInfoUtil.version; // "1.2.3"
packageInfoUtil.buildNumber; // "42"
packageInfoUtil.appName;
packageInfoUtil.packageName; // "com.mycompany.myapp"
packageInfoUtil.installerSource; // appStore, playStore, amazonStore, sideloaded, unknown
packageInfoUtil.buildSignature; // Android signing cert or iOS profile idPackageInfoImpl reads the single PackageInfo that package_info_provider registers. feedback_sdk and rating_review_sdk share it, so there is no duplicate registration.
Step 6: Test
device_info_impl reads the platform while DI starts. It ships a DeviceInfoTestPrerequisite that swaps in a fake. The generated injector_test installs it for you. See test prerequisites.
Common Customizations
| Customization | Where to Change |
|---|---|
| Add device fields | DeviceInfo in device_info_api and DeviceInfoImpl |
| Mock in tests | Register a fake DeviceInfoService |
| Disable a module | Generate again with the flag set to false |
Next Steps
- Set up Auth for sign-in flows
- Configure Monitoring to attach device info to crash reports