device_meta 2.0.2 copy "device_meta: ^2.0.2" to clipboard
device_meta: ^2.0.2 copied to clipboard

Basic information about the user's device. Fetch the device's model, manufacturer, operating system, version and more.

example/lib/main.dart

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:device_meta/device_meta.dart';

void main() async {
  DeviceMeta deviceMeta = await DeviceMeta.init(storageKey: "example");
  if (kDebugMode) {
    print(['deviceMeta.toJson', deviceMeta.toJson()]);
  }

  runApp(const MyApp());
}

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(),
    );
  }
}

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

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  // This is a simple example of how to use device meta.
  @override
  Widget build(BuildContext context) {
    DeviceMeta deviceMeta = DeviceMeta.instance;
    return Scaffold(
      appBar: AppBar(title: const Text("Device Meta")),
      body: SafeArea(
        child: Container(
          padding: const EdgeInsets.symmetric(horizontal: 8),
          width: double.infinity,
          child: ListView(
            shrinkWrap: true,
            children: [
              Text("Device meta",
                  style: Theme.of(context).textTheme.displaySmall),
              const Divider(),
              Text("Model: ${deviceMeta.model}"),
              Text("Version: ${deviceMeta.version}"),
              Text("Brand: ${deviceMeta.brand}"),
              Text("Manufacturer: ${deviceMeta.manufacturer}"),
              Text("Platform Type: ${deviceMeta.platformType}"),
              Text("UUID: ${deviceMeta.uuid}"),
              Text("UserAgent: ${deviceMeta.userAgent}"),
              Text("toJson: ${DeviceMeta.instance.toJson().toString()}"),
            ],
          ),
        ),
      ),
    );
  }
}
7
likes
0
points
1.43k
downloads

Publisher

verified publishernylo.dev

Weekly Downloads

Basic information about the user's device. Fetch the device's model, manufacturer, operating system, version and more.

Homepage
Repository (GitHub)
View/report issues

Topics

#device-info #device-meta #operating-system

Funding

Consider supporting this project:

github.com

License

unknown (license)

Dependencies

device_info_plus, flutter, nylo_support, universal_platform, uuid

More

Packages that depend on device_meta