tilt 0.0.2 copy "tilt: ^0.0.2" to clipboard
tilt: ^0.0.2 copied to clipboard

Easy access to the current tilt on `x` and `y` axis.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:tilt/tilt.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: StreamBuilder<Tilt>(
            stream: DeviceTilt(
              samplingRateMs: 20,
              initialTilt: const Tilt(0, 0),
              filterGain: 0.1,
            ).stream,
            builder: (context, snapshot) {
              if (snapshot.hasData && snapshot.data != null) {
                return Text(snapshot.data!.toString());
              }
              return const CircularProgressIndicator();
            },
          ),
        ),
      ),
    );
  }
}
4
likes
120
pub points
64%
popularity

Publisher

unverified uploader

Easy access to the current tilt on `x` and `y` axis.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, sensors_plus, stream_transform

More

Packages that depend on tilt