패키지, 저장소 및 앱 카테고리 검색

motion 표지
패키지 상세v2.0.3

motion

자식에 자이로스코프 또는 호버 기반의 모션 효과를 적용하는 세련된 위젯입니다.

AndroidiOSWeb
30일 다운로드
869
좋아요
289
Pub 점수
150

패키지 설치

flutter pub add motion

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

모션 패키지는 자이로스코프 또는 호버 기반의 동적 움직임 효과를 하위 위젯에 적용하여 사용자 경험을 향상시킵니다. 장치의 움직임이나 커서 위치에 반응하는 상호작용형 및 몰입형 애니메이션을 가능하게 하며, 모바일 및 웹 플랫폼에서 매력적인 UI를 만들기에 적합합니다. 이 패키지는 가볍고 최소한의 설정으로 Flutter 프로젝트에 원활하게 통합됩니다. Android 및 iOS 기기뿐 아니라 웹 브라우저도 지원하여 크로스플랫폼 개발에 매우 유연합니다. 버튼, 카드 또는 배경에 미묘한 깊이와 반응성을 추가하기에 이상적입니다.

사용 사례

  • 인터랙티브 앱 인터페이스
  • 자이로스코프 반응형 사용자 인터페이스 요소
  • 웹 기반의 호버 애니메이션
  • 카드 또는 버튼 피드백 향상
  • 몰입형 로딩 페이지 만들기

주요 기능

  • 자이로스코프 기반 운동
  • 호버 기반 애니메이션 지원
  • 크로스 플랫폼 호환성
  • 기존 위젯과의 간단한 통합
  • 부드럽고 성능이 뛰어난 애니메이션

적합한 대상

  • 인터랙티브한 UI를 찾는 개발자
  • 동적 시각 피드백을 원하는 디자이너
  • 모바일 및 웹 대상 프로젝트
  • 현대적이고 매력적인 사용자 경험을 목표로 하는 앱
  • 반응형 모션 효과 프로토타이핑

고려 사항

  • 저사양 기기에서 성능에 영향을 미칠 수 있습니다
  • 자이로스코프 모드를 사용하려면 기기 센서가 필요합니다
  • 웹 지원은 브라우저 기능에 따라 달라집니다
  • 기본적인 움직임 매개변수 외에 사용자 정의가 제한적입니다
  • 정적 또는 미니멀리스트 디자인에 적합하지 않습니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Motion for Flutter widgets

pub package

This package adds a new Motion widget that applies a gyroscope-based effect to Flutter widgets. On desktop or when the gyroscope in not available, the effect is based on the pointer's hovering.

Check out the live demo !

"Demo of the Motion plugin"

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

cd example/
flutter run --release

How to use

First, add the dependency to your pubspec.yaml file:

dependencies:
  motion: ^<latest-version>

Then, initialize the Motion plugin at Dart runtime, before running your Flutter app :

Future<void> main() async {

  /// Initialize the plugin.
  await Motion.instance.initialize();

  /// Run your app.
  runApp(...);

}

Finally, wrap your target widget as child of a Motion widget. You may optionally provide a MotionController instance that will hold individual widget's transformations (useful for pointer based events). The simplest usage of this widget is the following :


import 'package:motion/motion.dart';

...

return Motion(child: myWidget);

Custom behavior

Elevation

To remain consistent with the Material design language, you can pass an elevation parameter to the widget by using the Motion.elevated constructor.

It will influence the offset, opacity and blurriness of the shadow. Possible values for elevation range between 0 and 100.

"Elevations examples"

Comparing different elevation values

Shadow

The shadow is optional and depends, when using the Motion.elevated constructor, on the elevation value. The higher the elevation, the blurrier and the lower from behind the widget the shadow will get. The amplitude of the shadow's movement also depends on the widget's elevation. This aims to achieve the same behavior as Material design language's notion of elevation.

"Shadow effect comparison"

Comparing with and without the shadow effect

By default, the shadow is enabled but you can disable it by constructing the Motion widget with shadow: null or by using the Motion.only constructor.

Glare

The glare effect is also optional. It is a very subtle gradient overlay that confers a reflective feel to the widget. This effect is not rendered on Safari iOS due to limitations on gradients performances.

"Glare effect comparison"

Comparing with and without the glare effect

Also enabled by default, you can disable this effect by constructing the Motion widget with glare: false or by using the Motion.only constructor.

Custom effects configurations

You can provide custom configurations for the glare, shadow and translation effects by passing GlareConfiguration, ShadowConfiguration and TranslationConfiguration to the Motion and Motion.only constructors. When omitted, the default values will be used, unless if you use the Motion.only constructor which only applies the tilt effect by default.

Damping

By default, the widget will naturally rotate back to its original position if the phone stops rotating. This intends to improve the user experience by preserving the widget's legibility as much as possible. This property is only applied to gyroscope events and is ignored in pointer events.

The damping property of your MotionController allows you to fine tune or disable this behavior. By providing a value between 0 and 1, you can change the speed at which the widget rotates back to its original position. Explicitly providing null disables this effect.

The default value is 0.2.

Update interval

By default, the sensor's update and pointer events intervals are set to 60 frames per second.

Higher values will result in more accurate motion data and thus smoother motion of the widgets, but will also have an increased impact on performances.

Ideally, the update interval should match Flutter's recommended 60 FPS (frames per seconds). However, a performance compromise may be required on certain older devices. In that case, you could use the standard 30 FPS or 24 FPS, the latter being the lowest frame rate required to make motion appear natural to the human eye.

The best practice for setting the sensor rate is to do it once, when initializing your app, like so :

void main() {

  /// Initialize the plugin.
  await Motion.instance.initialize();

  /// Globally set the sensors sampling rate to 60 frames per second.
  Motion.instance.setUpdateInterval(60.fps);

  /// Run your app.
  runApp(...);

}

Filter quality

The Motion widget implementation wraps the child with a matrix-based Transform widget. On most platforms, it is a good practice to have it set to FilterQuality.medium or FilterQuality.high. You may specify it directly from the widget's constructor :

  Motion(
    filterQuality: FilterQuality.high,
    child: ...
  )

However, please note that due to limitations on Safari iOS, it is always enforced to null in this specific browser.

Some developers have reported issues when using FilterQuality.high on the Web in certain Flutter 3 versions. You may need to check kIsWeb and use a different value, depending on the versions of Flutter you're using.

The default value is FilterQuality.high.

Permission

This implementation is optional. You may skip but Motion widgets will have no effect on any iOS 13+ Safari browser.

Starting from iOS 13, the Safari browser requires to call DeviceMotionEvent.requestPermission() to listen to devicemotion events. This permission must be requested upon user gesture, otherwise the Promise will automatically be rejected.

To detect if the permission is required, you can check the Motion.instance.isPermissionRequired property after calling Motion.instance.initialize().

If required, you can either call Motion.requestPermission() after presenting the user a rationale dialog or after pressing a button. An implementation can be found in the example app.

No other platform permission to access sensor data is implemented for now.

Contribution Guide

If you are having any problem with the Motion package, you can file an issue on the package repo's issue tracker.

Please make sure that your concern hasn't already been addressed in the "Closed" section. Although we try to take care of every issue in a timely manner, please always remember that open source maintainers owe you nothing.

Whether you're running into an error you think you could fix or if you want other features — if you're unhappy with the outcome of your proposal, please do not republish this package under a different name. Instead, you should depend on your own GitHub fork of the plugin without affecting every other developers who may not share your point of view.

Thank you for your understanding !

Credits

This package was developed with ♥ by @mrcendre.

Thanks to @sebstianbuechler and @ekasetiawans for their contributions !

카테고리

의존성

의존성 목록 3 개

  • motion_platform_interface^2.0.2
  • motion_web^2.0.2
  • vector_math^2.4.3

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.