搜尋套件、儲存庫與 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 項

原始碼儲存庫

使用此套件的專案