Viewing version 0.2.6+3. Open the latest package page.

popover

0.2.6+3

A popover is a transient view that appears above other content onscreen when you tap a control or in an area.

Download archive

Readme

Content

Features

A popover is a transient view that appears above other content onscreen when you tap a control or in an area. Typically, a popover includes an arrow pointing to the location from which it emerged. Popovers can be nonmodal or modal. A nonmodal popover is dismissed by tapping another part of the screen or a button on the popover. A modal popover is dismissed by tapping a Cancel or other button on the popover.

Source: Human Interface Guidelines.

Requirements

  • Dart: 2.12.0+
  • Flutter : 2.0.0+

Install

dependencies:
  popover: ^0.2.6+3

Example

See example/lib/main.dart.

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

class PopoverExample extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('Popover Example')),
        body: const SafeArea(
          child: Padding(
            padding: EdgeInsets.all(16),
            child: Button(),
          ),
        ),
      ),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Container(
      width: 80,
      height: 40,
      decoration: const BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.all(Radius.circular(5)),
        boxShadow: [BoxShadow(color: Colors.black26, blurRadius: 5)],
      ),
      child: GestureDetector(
        child: const Center(child: Text('Click Me')),
        onTap: () {
          showPopover(
            context: context,
            transitionDuration: const Duration(milliseconds: 150),
            bodyBuilder: (context) => const ListItems(),
            onPop: () => print('Popover was popped!'),
            direction: PopoverDirection.top,
            width: 200,
            height: 400,
            arrowHeight: 15,
            arrowWidth: 30,
          );
        },
      ),
    );
  }
}

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

  @override
  Widget build(BuildContext context) {
    return Scrollbar(
      child: Padding(
        padding: const EdgeInsets.symmetric(vertical: 8),
        child: ListView(
          padding: const EdgeInsets.all(8),
          children: [
            InkWell(
              onTap: () {
                Navigator.of(context)
                  ..pop()
                  ..push(
                    MaterialPageRoute<SecondRoute>(
                      builder: (context) => SecondRoute(),
                    ),
                  );
              },
              child: Container(
                height: 50,
                color: Colors.amber[100],
                child: const Center(child: Text('Entry A')),
              ),
            ),
            const Divider(),
            Container(
              height: 50,
              color: Colors.amber[200],
              child: const Center(child: Text('Entry B')),
            ),
            const Divider(),
            Container(
              height: 50,
              color: Colors.amber[300],
              child: const Center(child: Text('Entry C')),
            ),
          ],
        ),
      ),
    );
  }
}

class SecondRoute extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Second Route'),
        automaticallyImplyLeading: false,
      ),
      body: Center(
        child: ElevatedButton(
          onPressed: () => Navigator.pop(context),
          child: const Text('Go back!'),
        ),
      ),
    );
  }
}

To see examples of the following package on a device or simulator:

cd example && flutter run

Support

Post issues and feature requests on the GitHub issue tracker.

License

The source code of Popover project is available under the MIT license. See the LICENSE file for more info.

Changelog

[0.2.6+3] - 12.10.2021

  • Fixed the bug that appears when the parent widget from which Popover was presented has been removed from a widget tree (thanks @ajaxspace).

[0.2.6+2] - 17.06.2021

  • Fixed the bug that appears when you change window size while popover is opened (thanks @whitebug).

[0.2.6+1] - 21.05.2021

  • Set minimum dart version to 2.12.0.

[0.2.6] - 21.05.2021

  • Fix constraints size for PopoverDirection.top & PopoverDirection.bottom.

[0.2.5] - 18.05.2021

  • Recalculate popover shape on context changes.

[0.2.4] - 17.05.2021

[0.2.3] - 03.05.2021.

  • Add RouteSettings? routeSettings parameter.

[0.2.2] - 22.04.2021.

[0.2.1] - 04.04.2021.

  • Lower minimum version requirements for Dart and Flutter to pass pub.dev validation.

[0.2.0] - 04.04.2021.

  • Migrate to NNBD.

[0.1.0] - 09.02.2021.

  • BREAKING: Refactor popover implementation to have identical API to included in Flutter modal dialogs e.g. showCupertinoDialog
  • docs: README updates
  • docs: example application updates

[0.0.5] - 08.02.2021.

  • Add Key key, barrierDismissible and showPopover.

[0.0.4] - 27.01.2021.

  • Add arrowDyOffset, arrowDxOffset and contentDyOffset public parameters.

[0.0.3] - 21.01.2021.

  • A child widget can be wrapped in InkWell or GestureDetector.

[0.0.2] - 18.01.2021.

  • Update PopoverItem.
  • Add PopoverDirection to exports.
  • Add documentation.

[0.0.1] - 10.01.2021.

  • Initial release.

Installing

export PUB_HOSTED_URL=https://pub.mirror.p-hatan.com
flutter pub add 'popover:0.2.6+3'
pubspec.yaml
name: popover
description: A popover is a transient view that appears above other content onscreen when you tap a control or in an area.
version: 0.2.6+3
homepage: https://github.com/minikin/popover

environment:
  sdk: ">=2.12.0 <3.0.0"
  flutter: ">=2.0.0"

dependencies:
  flutter:
    sdk: flutter

dev_dependencies:
  flutter_test:
    sdk: flutter

Version history

VersionPublishedArchiveSHA-256
0.0.1Cached · Upstream SHA-256 matchedDownload88b01eda…bf5273
0.0.2Cached · Upstream SHA-256 matchedDownload9d6da05b…208a73
0.0.3Cached · Upstream SHA-256 matchedDownload75ec1dcf…f85d1b
0.0.4Cached · Upstream SHA-256 matchedDownload8c08d042…4752cf
0.0.5Cached · Upstream SHA-256 matchedDownload092ea635…f05a8f
0.1.0Cached · Upstream SHA-256 matchedDownloadecd0913b…e14e10
0.2.0Cached · Upstream SHA-256 matchedDownloadddc74c59…95811d
0.2.1Cached · Upstream SHA-256 matchedDownloadc0e7ba46…655291
0.2.2Cached · Upstream SHA-256 matchedDownload07285f1e…5b800f
0.2.3Cached · Upstream SHA-256 matchedDownload086d8b1a…2a1301
0.2.4Cached · Upstream SHA-256 matchedDownloadd48bb7a4…2234a1
0.2.5Cached · Upstream SHA-256 matchedDownloadfed0248e…d020e1
0.2.6Cached · Upstream SHA-256 matchedDownload379b0957…33ccc6
0.2.6+1Cached · Upstream SHA-256 matchedDownload93f3b1d8…3fe28b
0.2.6+2Cached · Upstream SHA-256 matchedDownload4dfba8a3…00b9c3
0.2.6+3Cached · Upstream SHA-256 matchedDownload58619214…01f933
0.2.7Cached · Upstream SHA-256 matchedDownloadfacec117…066d67
0.2.8Cached · Upstream SHA-256 matchedDownload29b40c42…f9cf5f
0.2.8+1Cached · Upstream SHA-256 matchedDownload4255a09e…3582ea
0.2.8+2Cached · Upstream SHA-256 matchedDownload59f4a55e…5a94d4
0.2.9Cached · Upstream SHA-256 matchedDownload6a0928cc…b88c3f
0.3.0Cached · Upstream SHA-256 matchedDownloadca3bef9d…203db2
0.3.0+1Cached · Upstream SHA-256 matchedDownload5cba40e0…5fc876
0.3.1Cached · Upstream SHA-256 matchedDownload0606f3e1…d0e1a2
0.4.0Cached · Upstream SHA-256 matchedDownload2b2e1c40…efff07
0.5.0Cached · Upstream SHA-256 matchedDownload12856153…0a6715
0.5.1Cached · Upstream SHA-256 matchedDownload0bad70fe…6d3d3b

Dependencies

flutter { "sdk": "flutter" }