aurora_context_kit 0.1.0 copy "aurora_context_kit: ^0.1.0" to clipboard
aurora_context_kit: ^0.1.0 copied to clipboard

A Flutter plugin that delivers a rich device context profile for Android and iOS.

example/lib/main.dart

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

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final _plugin = AuroraContextKit();
  DeviceContext? _context;
  String? _error;

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

  Future<void> _loadContext() async {
    try {
      final context = await _plugin.getDeviceContext();
      if (!mounted) {
        return;
      }
      setState(() {
        _context = context;
      });
    } catch (error) {
      if (!mounted) {
        return;
      }
      setState(() {
        _error = 'Failed to read device context: $error';
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('Aurora Context Kit Example')),
        body: Padding(
          padding: const EdgeInsets.all(16),
          child: _error != null
              ? Text(_error!)
              : _context == null
              ? const Center(child: CircularProgressIndicator())
              : ListView(
                  children: [
                    _row('Badge', _context!.contextBadge),
                    _row('Platform', _context!.platform),
                    _row('OS Version', _context!.osVersion),
                    _row('Model', _context!.deviceModel),
                    _row('Locale', _context!.locale),
                    _row('Time Zone', _context!.timeZone),
                    _row('24 Hour Clock', _context!.is24HourFormat.toString()),
                    _row(
                      'Physical Device',
                      _context!.isPhysicalDevice.toString(),
                    ),
                    _row('SDK Int', _context!.sdkInt?.toString() ?? 'n/a'),
                    _row('Manufacturer', _context!.manufacturer ?? 'n/a'),
                    _row('Brand', _context!.brand ?? 'n/a'),
                    _row('Hardware ID', _context!.hardwareIdentifier ?? 'n/a'),
                  ],
                ),
        ),
      ),
    );
  }

  Widget _row(String label, String value) {
    return Padding(
      padding: const EdgeInsets.only(bottom: 10),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          SizedBox(width: 130, child: Text('$label:')),
          Expanded(child: Text(value)),
        ],
      ),
    );
  }
}
1
likes
140
points
39
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin that delivers a rich device context profile for Android and iOS.

Repository (GitHub)
View/report issues

Topics

#flutter #plugin #android #ios #device

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on aurora_context_kit

Packages that implement aurora_context_kit