wearable_rotary 2.0.2 copy "wearable_rotary: ^2.0.2" to clipboard
wearable_rotary: ^2.0.2 copied to clipboard

PlatformAndroid

Flutter plugin that can listen to rotary events on Wear OS and Tizen Galaxy watch devices.

wearable_rotary #

pub package

Flutter plugin that can listen to rotary events on Wear OS and Tizen Galaxy watch devices.

Setup #

Android #

Add the following to MainActivity.kt:

import android.view.MotionEvent
import com.samsung.wearable_rotary.WearableRotaryPlugin

class MainActivity : FlutterActivity() {
    override fun onGenericMotionEvent(event: MotionEvent?): Boolean {
        return when {
            WearableRotaryPlugin.onGenericMotionEvent(event) -> true
            else -> super.onGenericMotionEvent(event)
        }
    }
}

Usage #

To use this plugin, add wearable_rotary as a dependency in your pubspec.yaml file.

dependencies:
  wearable_rotary: ^2.0.1

Then, import wearable_rotary in your Dart code.

// Import the package.
import 'package:wearable_rotary/wearable_rotary.dart';

// Be informed when an event (RotaryEvent.clockwise or RotaryEvent.counterClockwise) occurs.
StreamSubscription<RotaryEvent> rotarySubscription =
    rotaryEvents.listen((RotaryEvent event) {
  if (event.direction == RotaryDirection.clockwise) {
    // Do something.
  } else if (event.direction == RotaryDirection.counterClockwise) {
    // Do something.
  }
});

// Be sure to cancel on dispose.
rotarySubscription.cancel();

// Use [RotaryScrollController] to easily make scrolling widgets respond to rotary input.
ListView(controller: RotaryScrollController());

Supported devices #

  • Wear OS devices with rotary input (Galaxy Watch 4, Pixel Watch, etc.)
  • Galaxy Watch series (running Tizen 5.5)
15
likes
140
pub points
82%
popularity

Publisher

verified publishertizen.org

Flutter plugin that can listen to rotary events on Wear OS and Tizen Galaxy watch devices.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter

More

Packages that depend on wearable_rotary