gyro_provider 0.0.3 copy "gyro_provider: ^0.0.3" to clipboard
gyro_provider: ^0.0.3 copied to clipboard

A plugin that provides data from gyroscopes and rotation sensors and related handy widgets.

example/lib/main.dart

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

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

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: const GyroProviderTest(),
      ),
    );
  }
}

class GyroProviderTest extends StatelessWidget {
  const GyroProviderTest({super.key});
  void _onTap(BuildContext context) {
    showDialog(
      context: context,
      builder: (context) => Dialog(
        child: GyroProvider.skew(
          verticalLock: true,
          child: Container(
            color: Colors.blue,
            width: 100,
            height: 100,
          ),
        ),
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Center(
      child: Column(
        children: [
          GyroProvider(
            gyroscope: (vector) {
              print(vector);
            },
            rotation: (vector) {
              print(vector);
            },
            builder: (context, gyroscope, rotation) => Column(
              children: [
                const Text('gyroscope'),
                Text(gyroscope.x.toString()),
                Text(gyroscope.y.toString()),
                Text(gyroscope.z.toString()),
              ],
            ),
          ),
          const SizedBox(
            height: 100,
          ),
          GyroProvider.skew(
            verticalLock: true,
            child: Container(
              color: Colors.red,
              width: 100,
              height: 100,
            ),
          ),
          const SizedBox(
            height: 100,
          ),
          TextButton(
            onPressed: () => _onTap(context),
            child: const Text('Open Dialog'),
          ),
        ],
      ),
    );
  }
}
6
likes
0
points
17
downloads

Publisher

unverified uploader

Weekly Downloads

A plugin that provides data from gyroscopes and rotation sensors and related handy widgets.

Homepage

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on gyro_provider

Packages that implement gyro_provider