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

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!'),
          ),
        ),
      ),
    );
  }
}
8
likes
160
points
38
downloads

Publisher

unverified uploader

Weekly Downloads

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

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on platform_builder