搜索插件、代码仓与 APP 分类

backdrop 封面
插件详情v0.9.1

backdrop

Dart 中的背景实现。(https://material.io/design/components/backdrop.html)

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
1.2万
喜欢数
601
Pub 分数
150

安装插件

flutter pub add backdrop

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

Backdrop 是一个 Flutter 包,实现了 Material Design Backdrop 组件,可实现主内容区域与次要面板(如抽屉或弹出层)之间的流畅过渡。它支持带有视差效果的交互式 backdrop 和可自定义的动画。该包适用于 Android、iOS、Web、macOS、Windows 和 Linux,通过提供直观的导航和分层界面来提升用户体验。该包可使用标准小部件模式无缝集成到 Flutter 应用中。

适合场景

  • 创建滑动侧边面板
  • 实现带有视差效果的交互式背景
  • 构建响应式导航抽屉
  • 通过分层布局增强UI深度
  • 设计以移动设备为优先的界面组件

主要特点

  • 视差滚动效果
  • 平滑过渡动画
  • 可自定义的背景行为
  • 支持多个平台
  • 内置手势处理
  • 可扩展的部件结构

适合对象

  • 移动应用开发者
  • 使用 Material Design 的 UI/UX 设计师
  • 需要分层导航的应用
  • 开发复杂底部表单的开发者
  • 专注于完善用户交互的团队

使用建议

  • 需要了解 Flutter 的动画系统
  • 可能会影响低端设备的性能
  • 需要仔细设计以避免杂乱
  • 超出基本配置的自定义功能有限
  • 最适合特定布局模式,而非通用用途

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Flutter Community: backdrop

backdrop

pub.dev ci Demo Awesome Flutter Gitter All Contributors pub points popularity likes GitHub issues GitHub milestone GitHub stars GitHub forks Gitlab stars Gitlab forks

ARCHIVE NOTE: Backdrop was based on the Material 2 Backdrop specification, which is no longer actively maintained. Material 3 does not include a Backdrop specification. As a result, this package is no longer actively developed and is limited to maintenance and critical fixes.

Backdrop implementation in flutter.

This widget is in active development. Any contribution, idea, criticism or feedback is welcomed.

Quick links

Package https://pub.dev/packages/backdrop
API Docs https://pub.dev/documentation/backdrop/latest/backdrop/backdrop-library.html
Live Demo https://fluttercommunity.github.io/backdrop/demo/#/
Git Repo https://github.com/fluttercommunity/backdrop
Issue Tracker https://github.com/fluttercommunity/backdrop/issues
Chat Room https://gitter.im/flutter-backdrop

Usage

BackdropScaffold

Use BackdropScaffold instead of the standard Scaffold in your app. A backLayer and a frontLayer have to be defined for the backdrop to work.

BackdropScaffold(
  appBar: BackdropAppBar(
    title: Text("Backdrop Example"),
    actions: <Widget>[
      BackdropToggleButton(
        icon: AnimatedIcons.list_view,
      )
    ],
  ),
  backLayer: Center(
    child: Text("Back Layer"),
  ),
  frontLayer: Center(
    child: Text("Front Layer"),
  ),
)
BackdropScaffold example
Navigation with backdrop

To use backdrop for navigation, use the provided BackdropNavigationBackLayer as backLayer.

The BackdropNavigationBackLayer contains a property items representing the list elements shown on the back layer. The front layer has to be "manually" set depending on the current index, which can be accessed with the onTap callback.

int _currentIndex = 0;
final List<Widget> _pages = [Widget1(), Widget2()];

@override
Widget build(BuildContext context) {
  return MaterialApp(
    title: 'Backdrop Demo',
    home: BackdropScaffold(
      appBar: BackdropAppBar(
        title: Text("Navigation Example"),
        actions: <Widget>[
          BackdropToggleButton(
            icon: AnimatedIcons.list_view,
          )
        ],
      ),
      stickyFrontLayer: true,
      frontLayer: _pages[_currentIndex],
      backLayer: BackdropNavigationBackLayer(
        items: [
          ListTile(title: Text("Widget 1")),
          ListTile(title: Text("Widget 2")),
        ],
        onTap: (int position) => {setState(() => _currentIndex = position)},
      ),
    ),
  );
}
BackdropNavigationScaffold example
Accessing underlying backdrop functionalities

To access backdrop related functionalities, use Backdrop.of(context) to get underlying BackdropScaffoldState.

BackdropScaffoldState exposes various properties and methods like:

  • properties
    • animationController -> AnimationController
    • scaffoldKey -> GlobalKey<ScaffoldState>
    • isBackLayerConcealed -> bool
    • isBackLayerRevealed -> bool
  • methods
    • fling()
    • concealBackLayer()
    • revealBackLayer()

Note: Backdrop is an InheritedWidget and therefore like Scaffold.of, Theme.of and MediaQuery.of, the BuildContext context passed to Backdrop.of(context) should be of a Widget that is under the BackdropScaffold in the "widget tree". In other words, Backdrop.of called inside a widget where the BackdropScaffold is initalized will not work explicitly, since the context passed is of the widget that will build BackdropScaffold therefore above BackdropScaffold. This can be solved by either making a seperate Widget where Backdrop.of needs to be used and make it the "child" of BackdropScaffold or wrap the Backdrop.of usage around Builder widget so that the "correct" context (from Builder) is passed to Backdrop.of. This answere on SO and FWotW video on Builder gives a very good idea of how and why Builder works in later case.

For more information, check out sample code in the example directory, demo app with use-cases and code for it and API references generated by pub.dev.

Contribute

Check proposal documents for v1.0 and web&desktop milestones before you begin with any contibution.

  1. You'll need a GitHub account.
  2. Fork the repository.
  3. Pick an issue to work on from issue tracker.
  4. Implement it.
  5. Send merge request.
  6. Star this project.
  7. Become a hero!!

Features and bugs

Please file feature requests and bugs at the issue tracker.

Contributors ✨

Thanks goes to these wonderful people (emoji key):

Harsh Bhikadia
Harsh Bhikadia

💻 🤔 👀 📖 🚇 🚧
Felix
Felix

💻 📖 🐛 👀 💡 🚇 🚧
Bringmos
Bringmos

🐛
Greg Spencer
Greg Spencer

🐛
Jorge A Peroza M
Jorge A Peroza M

🐛 💻
Matt Newell
Matt Newell

🐛
Daniel Borges
Daniel Borges

🐛 💻
Felix Wortmann
Felix Wortmann

💻 👀 🐛
Pierre Grimaud
Pierre Grimaud

📖
Вадим
Вадим

💻
Danial Agh
Danial Agh

🐛
PembaTamang
PembaTamang

🐛
hassan
hassan

🐛
Yaroslav Pronin
Yaroslav Pronin

🐛 💻 👀
Enikuomehin Adejuwon
Enikuomehin Adejuwon

💻
Nwachi ifeanyichukwu Victor
Nwachi ifeanyichukwu Victor

💻
mockturtl
mockturtl

💻 📖 🐛
ritar
ritar

🐛
LorenzoVianello
LorenzoVianello

🐛
Scott
Scott

💻
Sachin Dahal
Sachin Dahal

📖
Jan Hendrych
Jan Hendrych

🐛
Pascal Wild
Pascal Wild

🐛
Jens Reinemuth
Jens Reinemuth

💻
tobolski
tobolski

🐛
Mahdi Pishguy
Mahdi Pishguy

🐛

This project follows the all-contributors specification. Contributions of any kind welcome!

所属分类

源码仓库

使用此插件的项目