Skip to content

Software Development at Program Tom LTD

Place for coding, programming, development and software in general.

Menu
  • Blog
  • PDF Booklets
  • Dev Utils & Content
  • Java Spring Boot Or Web Apps
  • English
    • български
    • English
    • Español
    • Português
    • हिन्दी
    • Русский
    • Deutsch
    • Français
    • Italiano
    • العربية
  • About Us
Menu
Flutter Sensors

Flutter Sensors

Posted on October 25, 2025 by Toma Velev

sensors_plus is a more up-to-date and widely-used package for accessing various sensors on mobile devices with flutter.

To use sensors_plus, first add the package to your pubspec.yaml file:

https://pub.dev/packages/sensors_plus

dependencies:
  sensors_plus: ^0.2.6

Then, import the package in your Dart file:

import 'package:sensors_plus/sensors_plus.dart';

You can access different types of sensors using the SensorManager class:

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> with SensorManager {
  String _accelerometerData = 'Accelerometer: ';
  String _gyroscopeData = 'Gyroscope: ';
  String _magnetometerData = 'Magnetometer: ';

  @override
  void initState() {
    super.initState();
    accelerometerEvents.listen((AccelerometerEvent event) {
      setState(() {
        _accelerometerData = 'X: ${event.x}, Y: ${event.y}, Z: ${event.z}';
      });
    });
    gyroscopeEvents.listen((GyroscopeEvent event) {
      setState(() {
        _gyroscopeData = 'X: ${event.x}, Y: ${event.y}, Z: ${event.z}';
      });
    });
    magnetometerEvents.listen((MagnetometerEvent event) {
      setState(() {
        _magnetometerData = 'X: ${event.x}, Y: ${event.y}, Z: ${event.z}';
      });
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Sensors Demo'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(_accelerometerData),
            Text(_gyroscopeData),
            Text(_magnetometerData),
          ],
        ),
      ),
    );
  }
}

sensors_plus provides a more comprehensive set of features and better support for various sensors, including:

  • Accelerometer
  • Gyroscope
  • Magnetometer
  • Orientation sensor (compass)
  • Light sensor
  • Proximity sensor
  • Step counter
  • Distance sensor

It also includes a SensorManager class that allows you to listen to sensor events in real-time.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

  • Feature Flags – Enable Functionality from the BackEnd
  • Integrating xAI Grok API with Spring Boot
  • How to Progresively Integrate AI
  • What is an AI Agent
  • Flutter image scaling

Categories

  • Apps (22)
  • ChatGPT (23)
  • Choosing a Framework (38)
  • Flutter (256)
  • Graphical User Interface (14)
  • Marketing (116)
  • Software Development (281)
  • Spring (44)
  • StartUp (22)
  • Uncategorized (14)
  • Uncategorized (4)
  • Vaadin (14)

Tags

Algorithms (9) crypto (29) flutterdev (39) General (86) Java (7) QR & Bar Codes (3) Software Dev Choices (33) Spring Boot (1) standards (1) Theme (3) User Authentication & Authorization (9) User Experience (10) Utilities (19) WordPress (11)

Product categories

  • All Technologies (84)
    • Flutter Apps (24)
    • GPT (4)
    • Java (38)
    • Native Android (3)
    • PHP (9)
    • Spring (Boot) / Quarkus (35)
    • Utils (15)
    • Vaadin 24+ (27)
    • Vaadin 8 (1)
  • Apps (18)
    • Employees DB (1)
    • Notes (6)
    • Personal Budget (1)
    • Recipes Book (1)
    • Stuff Organizer (1)
    • To-Do (2)
  • PDF Books (3)
  • Source Code Generators (8)

Recent Posts

  • Feature Flags – Enable Functionality from the BackEnd
  • Integrating xAI Grok API with Spring Boot
  • How to Progresively Integrate AI
  • What is an AI Agent
  • Flutter image scaling

Post Categories

  • Apps (22)
  • ChatGPT (23)
  • Choosing a Framework (38)
  • Flutter (256)
  • Graphical User Interface (14)
  • Marketing (116)
  • Software Development (281)
  • Spring (44)
  • StartUp (22)
  • Uncategorized (14)
  • Uncategorized (4)
  • Vaadin (14)