compass app

Trying to setup a simple compass app which reads Android device compass heading and returns as integer value shown within text widget.

Have custom action setup with following:
flutter_compass: ^0.8.0

// Automatic FlutterFlow imports
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
import '/custom_code/actions/index.dart'; // Imports other custom actions
import '/flutter_flow/custom_functions.dart'; // Imports custom functions
import 'package:flutter/material.dart';
// Begin custom action code
// DO NOT REMOVE OR MODIFY THE CODE ABOVE!

import 'package:flutter_compass/flutter_compass.dart';

Future<int> compassHeading() async {
  // create realtime compass value as integer
  int heading = await FlutterCompass.events.first;
  return heading.round();
}

Tried updating code errors using following code but doesn't allow me to save it. Keep getting "Unable to process return parameter. Are you sure you want to save?" Got this error after compiling code which indicated code was valid.


Future<CompassEvent> compassHeading() async {

// create realtime compass value as integer

CompassEvent heading = await FlutterCompass.events!.first;

return heading;

}

Have page action setup with:
Request Permissions - Location

Update App State - Set Value - Heading - Rebuild Current Page

Project is setup with Location Permission in order to access compass heading: "android.permission.ACCESS_COARSE_LOCATION"
"android.permission.ACCESS_FINE_LOCATION"

1
3 replies