搜尋套件、儲存庫與 APP 分類

popover 封面
套件詳情v0.5.1

popover

彈出框是在您點擊控制項或某個區域時,出現在螢幕上其他內容之上的暫時檢視。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
3.9萬
喜歡數
688
Pub 分數
160

安裝套件

flutter pub add popover

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

彈出視窗套件提供了一種靈活且平台感知的方式,用於在使用者互動觸發時顯示暫時性的浮動檢視,這些檢視會出現在其他內容之上。專為與按鈕或圖示等控制項搭配使用而設計,支援在 Android、iOS、Web、macOS、Windows 與 Linux 上實現順暢的動畫與適應性定位。該套件確保行為一致,同時尊重各平台的原生設計指南。非常適合用於上下文選單、工具提示或快速操作面板,而不會中斷主要 UI 流程。

適用情境

  • 顯示上下文選單
  • 顯示快速操作面板
  • 建立工具提示
  • 顯示表單驗證提示
  • 啟用內嵌編輯選項

主要特色

  • 跨平台相容性
  • 自適應定位
  • 流暢的動畫
  • 可自定內容
  • 支援觸控和指針事件
  • 響應螢幕邊界

適合對象

  • 開發互動式 UI 的開發者
  • 針對多個平台的 Teams
  • 需要上下文疊加的應用程式
  • 需要可重用彈出框的設計系統
  • 使用 Material 或 Cupertino 小部件的專案

使用建議

  • 需要正確處理取消手勢
  • 可能需要自訂樣式來處理複雜佈局
  • 大量並發彈出視窗的性能影響
  • 有限的內建主題選項
  • 不適用於持續內容

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Popover

Popover screenshots

Popover for Flutter

Supported platforms Popover is released under the MIT license. Effective Dart PRs welcome!
Current Build Status.

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: 3.9.0+
  • Flutter: 3.35.0+

Install

dependencies:
  popover: ^0.4.0

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,
            bodyBuilder: (context) => const ListItems(),
            onPop: () => print('Popover was popped!'),
            direction: PopoverDirection.bottom,
            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 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

This project accepts pull requests only.

If you've encountered a bug or have an improvement in mind, please open a PR with a minimal fix or a reproduction in the example app. See CONTRIBUTING.md for the full contribution process.

License

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

所屬分類

原始碼儲存庫

使用此套件的專案