raw_gnss 1.1.0+1 copy "raw_gnss: ^1.1.0+1" to clipboard
raw_gnss: ^1.1.0+1 copied to clipboard

Fetch Raw GNSS Data - GNSS Measurement Events, Navigation Messages, and Status Events

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:raw_gnss/gnss_status_model.dart';
import 'package:raw_gnss/raw_gnss.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: Scaffold(
        appBar: AppBar(
          title: Text("Demo"),
        ),
        body: HomeScreen(),
      ),
    );
  }
}

class HomeScreen extends StatefulWidget {
  @override
  _HomeScreenState createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> {
  var _hasPermissions = false;
  late RawGnss _gnss;

  @override
  void initState() {
    super.initState();

    _gnss = RawGnss();

    Permission.location
        .request()
        .then((value) => setState(() => _hasPermissions = value.isGranted));
  }

  @override
  Widget build(BuildContext context) => _hasPermissions
      ? StreamBuilder<GnssStatusModel>(
          builder: (context, snapshot) {
            if (snapshot.data == null) {
              return _loadingSpinner();
            } else {
              return ListView.builder(
                itemBuilder: (context, position) {
                  return ListTile(
                    title: Text(
                        "Satellite: ${snapshot.data!.status![position].azimuthDegrees}"),
                  );
                },
                itemCount: snapshot.data!.satelliteCount ?? 0,
              );
            }
          },
          stream: _gnss.gnssStatusEvents,
        )
      : _loadingSpinner();

  Widget _loadingSpinner() => const Center(child: CircularProgressIndicator());
}
18
likes
150
pub points
67%
popularity

Publisher

verified publisherjoshi.dev

Fetch Raw GNSS Data - GNSS Measurement Events, Navigation Messages, and Status Events

Repository

Documentation

API reference

License

BSD-2-Clause (license)

Dependencies

flutter

More

Packages that depend on raw_gnss