platform_builder 2.0.1 copy "platform_builder: ^2.0.1" to clipboard
platform_builder: ^2.0.1 copied to clipboard

outdated

A Flutter library for performing platform checks and building widgets based on platform.

example/lib/main.dart

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

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

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  initState() {
    super.initState();

    Platform.init(supportedPlatforms: [
      Platforms.web,
      Platforms.android,
      Platforms.iOS,
    ]);
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: PlatformBuilder(
            webBuilder: (_context) => const Text('You are on web!'),
            iOSBuilder: (_context) => const Text('You are on iOS!'),
            androidBuilder: (_context) => const Text('You are on Android!'),
          ),
        ),
      ),
    );
  }
}
7
likes
0
pub points
44%
popularity

Publisher

unverified uploader

A Flutter library for performing platform checks and building widgets based on platform.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, rxdart

More

Packages that depend on platform_builder