The speech to text in new service request is stop recording now

Microphone permission issue on IOS has been fixed also the delete option is working in IOS version now
main_design2.0
zaid_daoud 2 years ago
parent 54854ee9e8
commit bb5cc8eda6

@ -42,6 +42,11 @@ post_install do |installer|
project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= [
'$(inherited)',
## dart: PermissionGroup.microphone
'PERMISSION_MICROPHONE=1',
]
end
end
end

@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_sound/flutter_sound.dart';
import 'package:fluttertoast/fluttertoast.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:rive/rive.dart';
import 'package:test_sa/views/widgets/buttons/app_icon_button2.dart';
@ -71,6 +72,8 @@ class _RecordSoundState extends State<RecordSound> {
// await Permission.camera
PermissionStatus status = await Permission.microphone.request();
if (!status.isGranted) {
PermissionStatus status = await Permission.microphone.request();
Fluttertoast.showToast(msg: "Permission Denied");
return;
}
_rive.addController(SimpleAnimation('recording'));
@ -114,11 +117,11 @@ class _RecordSoundState extends State<RecordSound> {
@override
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.only(left: 12, right: 0),
padding: const EdgeInsets.only(left: 12, right: 0),
decoration: BoxDecoration(
color: Color(0xfff5f5f5),
color: const Color(0xfff5f5f5),
border: Border.all(
color: Color(0xffefefef),
color: const Color(0xffefefef),
),
borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
),

@ -16,13 +16,13 @@ class SpeechToTextButton extends StatefulWidget {
const SpeechToTextButton({Key key, this.controller, this.mini = false}) : super(key: key);
@override
_SpeechToTextButtonState createState() => _SpeechToTextButtonState();
SpeechToTextButtonState createState() => SpeechToTextButtonState();
}
class _SpeechToTextButtonState extends State<SpeechToTextButton> {
class SpeechToTextButtonState extends State<SpeechToTextButton> {
bool _speechEnabled = false;
SettingProvider _settingProvider;
SpeechToText _speechToText = SpeechToText();
final SpeechToText _speechToText = SpeechToText();
/// This has to happen only once per app
void _initSpeech() async {
@ -63,12 +63,15 @@ class _SpeechToTextButtonState extends State<SpeechToTextButton> {
@override
void initState() {
_initSpeech();
widget.controller.addListener(() {
setState(() {});
});
super.initState();
}
@override
void setState(VoidCallback fn) {
if (!this.mounted) return;
if (!mounted) return;
super.setState(fn);
}
@ -76,11 +79,11 @@ class _SpeechToTextButtonState extends State<SpeechToTextButton> {
Widget build(BuildContext context) {
_settingProvider = Provider.of<SettingProvider>(context);
return Container(
padding: EdgeInsets.only(left: 12, right: 12),
padding: const EdgeInsets.only(left: 12, right: 12),
decoration: BoxDecoration(
color: Color(0xfff5f5f5),
color: const Color(0xfff5f5f5),
border: Border.all(
color: Color(0xffefefef),
color: const Color(0xffefefef),
),
borderRadius: BorderRadius.circular(AppStyle.borderRadius * AppStyle.getScaleFactor(context)),
),
@ -95,8 +98,8 @@ class _SpeechToTextButtonState extends State<SpeechToTextButton> {
setState(() {});
},
)
: SizedBox.shrink(),
Spacer(),
: const SizedBox.shrink(),
const Spacer(),
TextButton(
onPressed: () {
if (_speechToText.isListening) return;
@ -110,7 +113,7 @@ class _SpeechToTextButtonState extends State<SpeechToTextButton> {
child: Text(_settingProvider.speechToText)),
GestureDetector(
child: _speechToText.isListening
? Icon(
? const Icon(
Icons.fiber_manual_record,
color: Colors.red,
)
@ -123,7 +126,11 @@ class _SpeechToTextButtonState extends State<SpeechToTextButton> {
Fluttertoast.showToast(msg: "microphone not available");
return;
}
_startListening();
if (_speechToText.isListening) {
_stopListening();
} else {
_startListening();
}
},
),
],

Loading…
Cancel
Save