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

outdated

by using this package you can Detection the platform on which the application is running.(identification Run From web,mobile device,desktop,mobile browser,desktop browser,etc.)

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:platform_detector/platform_detector.dart';
import 'package:platform_detector/widgets/platform_type_widget.dart';
import 'package:platform_detector_example/custom_widget/custom_widget.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        primarySwatch: PlatformDetector.platform.byName(
            // by this (method) set primarySwatch color for some platforms and other platform get color from defaultValue (white color).
            defaultValue: Colors.white,
            ifAndroid: Colors.green,
            ifWebWindows: Colors.blue,
            ifIOS: Colors.black),
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(
          PlatformDetector.platform.byType(
            // by this (method) set custom text in appbar (according platform type) .
            defaultValue: "",
            ifWeb: "This is Web Application.",
            ifDesktop: "This is Desktop Application.",
            ifMobile: "This is Mobile Application.",
          ),
        ),
      ),
      body: Center(
        child: PlatformDetectByType(
          // by this (method) set custom widget according platform type .
          ifWeb: CustomWidget(
            icon: Icons.web,
            text: "Web",
          ),
          ifDesktop: CustomWidget(
            icon: Icons.desktop_mac,
            text: "Desktop",
          ),
          ifMobile: CustomWidget(
            icon: Icons.phone_android,
            text: "Mobile",
          ),
        ),
      ),
    );
  }
}
9
likes
0
pub points
85%
popularity

Publisher

verified publisherea2.dev

by using this package you can Detection the platform on which the application is running.(identification Run From web,mobile device,desktop,mobile browser,desktop browser,etc.)

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, universal_html

More

Packages that depend on platform_detector