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

parallax_sensors_bg 封面
插件详情v1.0.1

parallax_sensors_bg

Flutter 包,可简化在页面背景中实现响应相应传感器检测的视差效果。

AndroidiOS
近 30 天下载
277
喜欢数
115
Pub 分数
140

安装插件

flutter pub add parallax_sensors_bg

插件介绍

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

一个 Flutter 包,使开发者能够创建动态视差背景,响应设备传感器数据(如加速度计和陀螺仪)。它通过根据实时传感器输入自动调整背景元素,简化了在应用界面中集成沉浸式、运动敏感视觉效果的过程。非常适合通过细微的响应式动画提升用户参与度。该包支持 Android 和 iOS 平台,并设计为在最少设置下实现流畅性能。

适合场景

  • 创建沉浸式应用入门屏幕
  • 在仪表板中添加动态响应背景
  • 增强游戏或交互式用户界面
  • 设计引人入胜的产品展示页面
  • 实施基于传感器的视觉叙事

主要特点

  • 基于传感器的实时视差效果
  • 低延迟的流畅动画
  • 跨平台支持(Android 和 iOS)
  • 所需最小配置
  • 支持自定义背景小部件
  • 针对性能进行了优化

适合对象

  • 寻求交互元素的UI/UX设计师
  • 开发运动感知应用的开发者
  • 需要引人注目的视觉反馈的应用程序
  • 游戏化或体验式移动界面
  • 原型设计交互式原型

使用建议

  • 需要设备传感器可用
  • 连续使用传感器可能影响电池寿命
  • 最适合静态或缓慢移动的背景
  • 不适合复杂的动画
  • 传感器灵敏度设置的控制有限

原始 README

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

Parallax Sensors Bg

Get a parallax effect in the background of a page that responds to a corresponding sensor detection (Accelerometer, Gyroscope, User accelerometer, Magnetometer)

Note: Accelerometer is preferred over other sensors.


Features

  • Supports 4 sensors: Accelerometer, User Accelerometer, Gyroscope, Magnetometer.
  • Simplified use of image.
  • Predefined filters for image: Blur and darken.
  • Any widgets can be used as a layer.
  • Can lock or reverse the movement of any axis.
  • Many parameters for precise customization.

Getting started

Add dependency in pubspec.yaml and run flutter pub get

dependencies:
  parallax_sensors_bg: ^1.0.0

Now import the package in your code:

import 'package:parallax_sensors_bg/parallax_sensors_bg.dart';

Usage

Use it in the Scaffold body

Parallax(
  sensors: ParallaxSensor.accelerometer,
  layers: [
    Layer(
      sensitivity: 1,
      image: NetworkImage('https://example.com/background.png'),
      preventCrop: true,
      imageBlurValue: 5,
    ),
    Layer(
      sensitivity: 7,
      image: AssetImage('assets/middle_layer.png'),
      imageHeight: 500,
      imageFit: BoxFit.fitHeight,
    ),
    Layer(
      sensitivity: 12,
      child: Text('Topmost layer'),
    ),
  ]
  child: Text('Page body here'),
),

Parallax class arguments:

Argument Type Default Description
sensor ParallaxSensor ParallaxSensor.accelerometer Type of the sensor whose detected values will be used for parallax movement. (accelerometer, userAccelerometer, gyroscope, magnetometer).
layers List<Layer> required Individual layers for the parallax effect. The declaration of the layers sequentially are positioned from bottom to top (Farthest to nearest from parallax perspective).
reverseVerticalAxis bool false Reverses the movement of vertical axis.
reverseHorizontalAxis bool false Reverses the movement of horizontal axis.
lockVerticalAxis bool false Stops the movement of vertical axis.
lockHorizontalAxis bool false Stops the movement of horizontal axis.
animationDuration int 300 The duration in milliseconds it takes for the movement change to complete. Ideal value is from 200 to 400.
child Widget? null The fixed body of the page, above the parallax layer.

Layer class arguments:

Argument Type Default Description
sensitivity double required Moving sensitivity of the layer.
offset Offset? null Position of the layer from the center.
image ImageProvider<Object>? null Image that the layer will show. By default, the image will take the size of the screen.
imageFit BoxFit BoxFit.cover BoxFit type of the image.
imageHeight double? null Height of the image.
imageWidth double? null Width of the image.
preventCrop bool false If set to true, it will ignore the imageHeight and imageWidth if given and will set the height and width of the image slightly more than the screen size such that it doesn't get cropped even at the extreme value of the sensor.
imageBlurValue double? null Blurs the image. Value can be any positive fractional number.
imageDarkenValue double? null Darkens the image. Value ranges from 0 to 1.
opacity double? null Opacity of the layer. Value ranges from 0 to 1.

所属分类

依赖

依赖清单 1 项

源码仓库

使用此插件的项目