multi_platform_widget 1.0.1
multi_platform_widget: ^1.0.1 copied to clipboard

A package which allows creating different widgets for each platform supported by Flutter.

example/lib/main.dart

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

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('Example'),
        ),
        body: Center(
          child: ExampleWidget(),
        ),
      ),
    );
  }
}

class ExampleWidget extends MultiPlatformWidget {
  Widget _getText(String text) => Text(
        text,
        style: TextStyle(fontSize: 20),
      );

  @override
  Widget get defaultWidget => _getText('Default');

  @override
  Widget? get androidWidget => _getText('Android');

  @override
  Widget? get fuchsiaWidget => _getText('Fuchsia');

  @override
  Widget? get iOSWidget => _getText('iOS');

  @override
  Widget? get linuxWidget => _getText('Linux');

  @override
  Widget? get macOSWidget => _getText('MacOS');

  @override
  Widget? get windowsWidget => _getText('Windows');

  @override
  Widget? get webWidget => _getText('Web');
}
3
likes
130
pub points
0%
popularity

Publisher

morabus.pl

A package which allows creating different widgets for each platform supported by Flutter.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on multi_platform_widget