Skip to content
Branch: master
Find file History
Latest commit 0b56d0c May 20, 2019
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
.idea
.vscode Adding mobile_popup May 6, 2019
example adding new plugin May 21, 2019
lib Adding options May 15, 2019
screenshots Adding mobile_popup May 6, 2019
.gitignore Adding mobile_popup May 6, 2019
.metadata
CHANGELOG.md
LICENSE Adding mobile_popup May 6, 2019
README.md Update README.md May 6, 2019
mobile_popup.iml Adding mobile_popup May 6, 2019
pubspec.yaml

README.md

mobile_popup

A Flutter plugin to show a PopUp Surface on Tablet / Desktop and for Mobile a Full Screen View. It will animate between them for a smooth experience. Check out the example for a demo.

Usage

showMobilePopup(
    context: context,
    builder: (context) => MobilePopUp(
        title: 'App Settings',
        leadingColor: Colors.white,
        builder: Builder(
            builder: (navigator) => Scaffold(
                body: SingleChildScrollView(
                    child: Column(
                    children: <Widget>[
                        ListTile(
                        leading: Icon(Icons.brightness_auto),
                        title: Text('Brightness'),
                        trailing: Switch.adaptive(
                            value: true,
                            onChanged: (value) {},
                        ),
                        ),
                        ListTile(
                        leading: Icon(Icons.fingerprint),
                        title: Text('Fingerprint'),
                        trailing: Switch.adaptive(
                            value: false,
                            onChanged: (value) {},
                        ),
                        ),
                        ListTile(
                        leading: Icon(Icons.map),
                        title: Text('Navigation'),
                        trailing: Switch.adaptive(
                            value: true,
                            onChanged: (value) {},
                        ),
                        ),
                    ],
                    ),
                ),
                ),
        ),
    ),
);

Screenshots

Example

import 'dart:io';

import 'package:flutter/material.dart';

import 'package:flutter/foundation.dart'
    show debugDefaultTargetPlatformOverride;
import 'package:mobile_popup/mobile_popup.dart';

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

/// If the current platform is desktop, override the default platform to
/// a supported platform (iOS for macOS, Android for Linux and Windows).
/// Otherwise, do nothing.
void _setTargetPlatformForDesktop() {
  TargetPlatform targetPlatform;
  if (Platform.isMacOS) {
    targetPlatform = TargetPlatform.iOS;
  } else if (Platform.isLinux || Platform.isWindows) {
    targetPlatform = TargetPlatform.android;
  }
  if (targetPlatform != null) {
    debugDefaultTargetPlatformOverride = targetPlatform;
  }
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: HomeScreen(),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Popup Example'),
      ),
      body: Center(
        child: RaisedButton(
          child: Text("Show Popup"),
          onPressed: () {
            showMobilePopup(
              context: context,
              builder: (context) => MobilePopUp(
                    title: 'App Settings',
                    leadingColor: Colors.white,
                    builder: Builder(
                      builder: (navigator) => Scaffold(
                            body: SingleChildScrollView(
                              child: Column(
                                children: <Widget>[
                                  ListTile(
                                    leading: Icon(Icons.brightness_auto),
                                    title: Text('Brightness'),
                                    trailing: Switch.adaptive(
                                      value: true,
                                      onChanged: (value) {},
                                    ),
                                  ),
                                  ListTile(
                                    leading: Icon(Icons.fingerprint),
                                    title: Text('Fingerprint'),
                                    trailing: Switch.adaptive(
                                      value: false,
                                      onChanged: (value) {},
                                    ),
                                  ),
                                  ListTile(
                                    leading: Icon(Icons.map),
                                    title: Text('Navigation'),
                                    trailing: Switch.adaptive(
                                      value: true,
                                      onChanged: (value) {},
                                    ),
                                  ),
                                ],
                              ),
                            ),
                          ),
                    ),
                  ),
            );
          },
        ),
      ),
    );
  }
}
You can’t perform that action at this time.