platform_plus 3.1.0 copy "platform_plus: ^3.1.0" to clipboard
platform_plus: ^3.1.0 copied to clipboard

Platform Plus is a package for easily figuring out information about the platform your code is running on

example/lib/main.dart

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

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'platform_plus_example',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        appBar: AppBar(
          title: const Text('platform_plus_example'),
        ),
        body: SingleChildScrollView(
          padding: const EdgeInsets.symmetric(vertical: 40),
          child: Center(
            child: Column(
              children: [
                Text(
                  'isAndroidNative: ${platformPlus.isAndroidNative}',
                ),
                Text('isAndroidWeb: ${platformPlus.isAndroidWeb}'),
                Text('isIOSNative: ${platformPlus.isIOSNative}'),
                Text('isIOSWeb: ${platformPlus.isIOSWeb}'),
                Text(
                  'isWindowsNative: ${platformPlus.isWindowsNative}',
                ),
                Text('isWindowsWeb: ${platformPlus.isWindowsWeb}'),
                Text('isMacOSNative: ${platformPlus.isMacOSNative}'),
                Text('isMacOSWeb: ${platformPlus.isMacOSWeb}'),
                Text('isLinuxNative: ${platformPlus.isLinuxNative}'),
                Text('isLinuxWeb: ${platformPlus.isLinuxWeb}'),
                Text(
                  'isFuschiaNative: ${platformPlus.isFuschiaNative}',
                ),
                Text('isFuschiaWeb: ${platformPlus.isFuschiaWeb}'),
                Text(
                  'supportsFirebase: ${platformPlus.supportsFirebase}',
                ),
                Text('isUnitTest: ${platformPlus.isUnitTest}'),
                FutureBuilder<bool>(
                  future: platformPlus.isPhysicalDevice,
                  builder: (context, snap) => Text(
                    'isPhysicalDevice: ${snap.data}',
                  ),
                ),
                FutureBuilder<int?>(
                  future: platformPlus.androidVersionCode,
                  builder: (context, snap) => Text(
                    'androidVersionCode: ${snap.data}',
                  ),
                ),
                FutureBuilder<double?>(
                  future: platformPlus.iosVersion,
                  builder: (context, snap) => Text('iosVersion: ${snap.data}'),
                ),
                FutureBuilder<IOSDevice>(
                  future: platformPlus.iosDevice,
                  builder: (context, snap) =>
                      Text('iosDevice: ${snap.data?.name}'),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
13
likes
150
pub points
82%
popularity

Publisher

verified publisherrexios.dev

Platform Plus is a package for easily figuring out information about the platform your code is running on

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

browser_detector, device_info_plus, flutter

More

Packages that depend on platform_plus