Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/leanflutter/uni_platform

Replaces the Platform class and works on any platform.
https://github.com/leanflutter/uni_platform

Last synced: 4 days ago
JSON representation

Replaces the Platform class and works on any platform.

Awesome Lists containing this project

README

        

# uni_platform

[![pub version][pub-image]][pub-url] [![][discord-image]][discord-url]

[pub-image]: https://img.shields.io/pub/v/uni_platform.svg
[pub-url]: https://pub.dev/packages/uni_platform
[discord-image]: https://img.shields.io/discord/884679008049037342.svg
[discord-url]: https://discord.gg/zPa6EZ2jqb

Substitutes the Platform class, ensuring works across all platforms.

---

- [Quick Start](#quick-start)
- [Installation](#installation)
- [Usage](#usage)
- [License](#license)

## Quick Start

### Installation

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

```yaml
dependencies:
uni_platform: ^0.1.1
```

### Usage

select method:

```dart
import 'package:uni_platform/uni_platform.dart';

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

call method:

```dart
String platformType = UniPlatform.call(
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](./LICENSE)