platform_detail 4.1.0 copy "platform_detail: ^4.1.0" to clipboard
platform_detail: ^4.1.0 copied to clipboard

A lightweight library to obtain details of the current platform in a much more complete and simple way.

example/lib/main.dart

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

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: MyHomePage(
          title:
              'Flutter Demo Home Page ${PlatformDetail.currentGroupPlatform.name}'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

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

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            FutureBuilder(
                future: PlatformDetail.deviceInfoDetails(),
                builder: (context, snapshot) {
                  if (snapshot.connectionState == ConnectionState.waiting) {
                    return CircularProgressIndicator();
                  } else if (snapshot.hasError) {
                    return Text('Error: ${snapshot.error}');
                  } else if (snapshot.hasData) {
                    return Text('Device Info: ${snapshot.data}');
                  } else {
                    return Text('No data available');
                  }
                })
          ],
        ),
      ),
    );
  }
}
16
likes
160
points
246
downloads

Publisher

verified publishervictorcarreras.dev

Weekly Downloads

A lightweight library to obtain details of the current platform in a much more complete and simple way.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

device_info_plus, flutter

More

Packages that depend on platform_detail