device_properties 0.0.1 copy "device_properties: ^0.0.1" to clipboard
device_properties: ^0.0.1 copied to clipboard

discontinued
outdated

get your device properties.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:device_properties/device_properties.dart';

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

class MyApp extends StatefulWidget {
  const MyApp({Key? key}) : super(key: key);

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

class _MyAppState extends State<MyApp> {
  DevicesPropertiesModel? _deviceProperties;
  final _devicePropertiesPlugin = DeviceProperties();

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

  Future<void> initPlatformState() async {
    DevicesPropertiesModel? deviceProperties;
    try {
      deviceProperties = await _devicePropertiesPlugin.getDevicesProperties();
    } on PlatformException {
      deviceProperties = null;
    }
    if (!mounted) return;

    setState(() {
      _deviceProperties = deviceProperties;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Device properties example app'),
        ),
        body: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
            ElevatedButton(
                onPressed: () {
                  initPlatformState();
                },
                child: const Text("Get device properties")),
            const SizedBox(height: 100),
            Text('Running on: ${_deviceProperties?.toJson() ?? ""}\n'),
          ],
        ),
      ),
    );
  }
}