|
|
|
|
@ -2,30 +2,23 @@ import 'dart:async';
|
|
|
|
|
|
|
|
|
|
import 'package:doctor_app_flutter/config/size_config.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/core/provider/robot_provider.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/util/translations_delegate_base.dart';
|
|
|
|
|
import 'package:doctor_app_flutter/widgets/shared/app_texts_widget.dart';
|
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'dart:async';
|
|
|
|
|
import 'package:speech_to_text/speech_to_text.dart' as stt;
|
|
|
|
|
|
|
|
|
|
class SpeechToText {
|
|
|
|
|
final BuildContext context;
|
|
|
|
|
static var dialog;
|
|
|
|
|
static stt.SpeechToText speech = stt.SpeechToText();
|
|
|
|
|
SpeechToText({
|
|
|
|
|
@required this.context,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
showAlertDialog(BuildContext context) {
|
|
|
|
|
//AlertDialog alert = AlertDialog
|
|
|
|
|
// AlertDialog alert = AlertDialog(content: MyStatefulBuilder(dispose: () {
|
|
|
|
|
// print('dispose!!!!!!!!!!!!');
|
|
|
|
|
// })
|
|
|
|
|
// isClosed = true;
|
|
|
|
|
// streamSubscription.cancel();
|
|
|
|
|
// }, builder: (BuildContext context, StateSetter setState) {
|
|
|
|
|
// //print(streamSubscription);
|
|
|
|
|
// }),
|
|
|
|
|
// );
|
|
|
|
|
|
|
|
|
|
// show the dialog
|
|
|
|
|
showDialog(
|
|
|
|
|
context: context,
|
|
|
|
|
@ -42,6 +35,7 @@ class SpeechToText {
|
|
|
|
|
|
|
|
|
|
static closeAlertDialog(BuildContext context) {
|
|
|
|
|
Navigator.of(dialog).pop();
|
|
|
|
|
speech.stop();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -93,14 +87,16 @@ class _MyStatefulBuilderState extends State<MyStatefulBuilder> {
|
|
|
|
|
width: SizeConfig.realScreenWidth * 0.8,
|
|
|
|
|
child: Container(
|
|
|
|
|
child: Column(children: [
|
|
|
|
|
Expanded(
|
|
|
|
|
flex: 1,
|
|
|
|
|
child: Center(
|
|
|
|
|
child: Image.asset(
|
|
|
|
|
'assets/images/habib-logo.png',
|
|
|
|
|
height: 75,
|
|
|
|
|
width: 75,
|
|
|
|
|
))),
|
|
|
|
|
Row(
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.end,
|
|
|
|
|
children: [
|
|
|
|
|
IconButton(
|
|
|
|
|
icon: Icon(DoctorApp.close),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
SpeechToText.closeAlertDialog(context);
|
|
|
|
|
})
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
Expanded(
|
|
|
|
|
flex: 3,
|
|
|
|
|
child: Center(
|
|
|
|
|
@ -126,19 +122,38 @@ class _MyStatefulBuilderState extends State<MyStatefulBuilder> {
|
|
|
|
|
Expanded(
|
|
|
|
|
flex: 1,
|
|
|
|
|
child: Center(
|
|
|
|
|
child: AppText(searchText != null && searchText != 'null'
|
|
|
|
|
? searchText
|
|
|
|
|
: TranslationBase.of(context).trySaying))),
|
|
|
|
|
child: AppText(
|
|
|
|
|
searchText == null
|
|
|
|
|
? TranslationBase.of(context).trySaying
|
|
|
|
|
: searchText == 'null'
|
|
|
|
|
? TranslationBase.of(context).didntCatch
|
|
|
|
|
: searchText,
|
|
|
|
|
fontSize: 14,
|
|
|
|
|
))),
|
|
|
|
|
searchText == 'null'
|
|
|
|
|
? Center(
|
|
|
|
|
child: RaisedButton(
|
|
|
|
|
child: AppText('Retry'),
|
|
|
|
|
onPressed: () {
|
|
|
|
|
child: InkWell(
|
|
|
|
|
child: Container(
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
border: Border.all(color: Colors.grey[300])),
|
|
|
|
|
padding: EdgeInsets.all(5),
|
|
|
|
|
child: AppText(
|
|
|
|
|
'Try Again',
|
|
|
|
|
fontSize: 13,
|
|
|
|
|
)),
|
|
|
|
|
onTap: () {
|
|
|
|
|
SpeechToText.closeAlertDialog(context);
|
|
|
|
|
event.setValue({'startPopUp': 'true'});
|
|
|
|
|
},
|
|
|
|
|
))
|
|
|
|
|
: SizedBox()
|
|
|
|
|
: SizedBox(),
|
|
|
|
|
Row(mainAxisAlignment: MainAxisAlignment.end, children: [
|
|
|
|
|
Image.asset(
|
|
|
|
|
'assets/images/habib-logo.png',
|
|
|
|
|
height: 20,
|
|
|
|
|
width: 20,
|
|
|
|
|
)
|
|
|
|
|
])
|
|
|
|
|
]),
|
|
|
|
|
)));
|
|
|
|
|
|
|
|
|
|
|