page_dialog 0.0.1 copy "page_dialog: ^0.0.1" to clipboard
page_dialog: ^0.0.1 copied to clipboard

A way to simplify handling tablet/desktop/phone.

example/lib/main.dart

import 'package:flutter/material.dart';

import 'package:page_dialog/page_dialog.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Page dialog app'),
        ),
        body: Center(
          child: PageDialogButton(),
        ),
      ),
    );
  }
}

class PageDialogButton extends StatelessWidget {
  const PageDialogButton({
    Key key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return ElevatedButton(
      child: Text('What will happen ?'),
      onPressed: () {
        showPageDialog(
          context,
          routeOnPhone: MaterialPageRoute(
            builder: (context) => Text('on phone'),
          ),
          desktopBuilder: (_) => Dialog(child: Text('on desktop')),
          tabletBuilder: (_) => Dialog(child: Text('on tablet')),
          onWeb: (_) => showDialog(
              context: context, builder: (_) => Dialog(child: Text('on web'))),
        );
      },
    );
  }
}
0
likes
30
pub points
0%
popularity

Publisher

unverified uploader

A way to simplify handling tablet/desktop/phone.

Homepage

License

BSD-3-Clause (LICENSE)

Dependencies

flutter, flutter_device_type, flutter_web_plugins, platform

More

Packages that depend on page_dialog