I have a custom action and it says custom action Noisemeter not found.

Actions & Logic

Please help I don't know what I'm doing wrong. When I add in this custom action then try to save it , Flutterflow will say Noisemeter action declaration not found which then leads to the custom action not being saved. Here is my custom action code :

import 'dart:async';

import 'package:noise_meter/noise_meter.dart';

import 'package:flutter/material.dart';

import 'package:permission_handler/permission_handler.dart';

void main() => runApp(NoiseMeterApp());

class NoiseMeterApp extends StatefulWidget {

@override

NoiseMeterAppState createState() => NoiseMeterAppState();

}

class _NoiseMeterAppState extends State<NoiseMeterApp> {

bool _isRecording = false;

NoiseReading? _latestReading;

StreamSubscription<NoiseReading>? _noiseSubscription;

NoiseMeter? noiseMeter;

@override

void dispose() {

_noiseSubscription?.cancel();

super.dispose();

}

void onData(NoiseReading noiseReading) =>

setState(() => _latestReading = noiseReading);

void onError(Object error) {

print(error);

stop();

}

/// Check if microphone permission is granted.

Future<bool> checkPermission() async => await Permission.microphone.isGranted;

/// Request the microphone permission.

Future<void> requestPermission() async =>

await Permission.microphone.request();

/// Start noise sampling.

Future<void> start() async {

// Create a noise meter, if not already done.

noiseMeter ??= NoiseMeter();

// Check permission to use the microphone.

//

// Remember to update the AndroidManifest file (Android) and the

// Info.plist and pod files (iOS).

if (!(await checkPermission())) await requestPermission();

// Listen to the noise stream.

_noiseSubscription = noiseMeter?.noise.listen(onData, onError: onError);

setState(() => _isRecording = true);

}

/// Stop sampling.

void stop() {

_noiseSubscription?.cancel();

setState(() => _isRecording = false);

}

@override

Widget build(BuildContext context) => MaterialApp(

home: Scaffold(

body: Center(

child: Column(

mainAxisAlignment: MainAxisAlignment.center,

children: [

Container(

margin: EdgeInsets.all(25),

child: Column(children: [

Container(

child: Text(_isRecording ? "Mic: ON" : "Mic: OFF",

style: TextStyle(fontSize: 25, color: Colors.blue)),

margin: EdgeInsets.only(top: 20),

),

Container(

child: Text(

'Noise: ${_latestReading?.meanDecibel.toStringAsFixed(2)} dB',

),

margin: EdgeInsets.only(top: 20),

),

Container(

child: Text(

'Max: ${_latestReading?.maxDecibel.toStringAsFixed(2)} dB',

),

)

])),

])),

floatingActionButton: FloatingActionButton(

backgroundColor: _isRecording ? Colors.red : Colors.green,

child: _isRecording ? Icon(Icons.stop) : Icon(Icons.mic),

onPressed: _isRecording ? stop : start,

),

),

);

}

What have you tried so far?

I have tried Noisemeter and Noisereading and noisemeterapp as it's custom action names but it should just be start() right? and if yes then how do I write in () into the custom action name field cause' flutterflow isn't letting me write in () into the custom action name textfield.

Did you check FlutterFlow's Documentation for this topic?
No
1
1 reply