leanflutter / uni_platform

Replaces the Platform class and works on any platform.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

uni_platform

pub version

Substitutes the Platform class, ensuring works across all platforms.


Quick Start

Installation

Add this to your package's pubspec.yaml file:

dependencies:
  uni_platform: ^0.1.1

Usage

select method:

import 'package:uni_platform/uni_platform.dart';

String platformType = UniPlatform.select<String>(
  android: 'Android',
  fuchsia: 'Fuchsia',
  ios: 'iOS',
  linux: 'Linux',
  macos: 'macOS',
  windows: 'Windows',
  web: 'Web',
  otherwise: 'Unknown',
);

call method:

String platformType = UniPlatform.call<String>(
  android: () => 'Android',
  fuchsia: () => 'Fuchsia',
  ios: () => 'iOS',
  linux: () => 'Linux',
  macos: () => 'macOS',
  windows: () => 'Windows',
  web: () => 'Web',
  otherwise: () => 'Unknown',
);

Please see the example app of this plugin for a full example.

License

MIT

About

Replaces the Platform class and works on any platform.

License:MIT License


Languages

Language:Dart 76.0%Language:Ruby 10.3%Language:HTML 6.8%Language:Swift 6.3%Language:Kotlin 0.5%Language:Objective-C 0.1%