[go: nahoru, domu]

Skip to content

Commit

Permalink
Merge pull request #22 from chandansgowda/master
Browse files Browse the repository at this point in the history
single button to start/stop recording stream
  • Loading branch information
TheGuyDangerous committed Nov 12, 2022
2 parents 582d328 + b860e28 commit a30e7c4
Showing 1 changed file with 21 additions and 26 deletions.
47 changes: 21 additions & 26 deletions lib/Screens/continuous.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class _ContinuousVoiceAppState extends State<ContinuousVoiceApp> {

late IOWebSocketChannel channel;

bool _isServiceActive = false;

@override
void initState() {
super.initState();
Expand Down Expand Up @@ -236,32 +238,25 @@ class _ContinuousVoiceAppState extends State<ContinuousVoiceApp> {
//record button starts
padding: const EdgeInsets.only(
bottom: 24.0, left: 24.0, right: 24.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
FloatingActionButton(
onPressed: () {
updateText('');

_startRecord();
},
backgroundColor: Colors.green,
child: const Icon(
Icons.mic,
color: Colors.white,
),
),
const SizedBox(
width: 76,
height: 76,
),
FloatingActionButton(
heroTag: "btn2",
backgroundColor: Colors.redAccent,
onPressed: () => _stopRecord(),
child: const Icon(Icons.stop, color: Colors.white),
),
],
child: ElevatedButton(
onPressed: () {
if (_isServiceActive) {
_stopRecord();
_isServiceActive = false;
} else {
updateText('');
_isServiceActive = true;
_startRecord();
}
},
child: Icon(_isServiceActive ? Icons.stop : Icons.mic,size: 40,),
style: ElevatedButton.styleFrom(
shape: CircleBorder(),
padding: EdgeInsets.all(15),
backgroundColor: _isServiceActive
? Colors.red
: Colors.green,
)
),
)
],
Expand Down

0 comments on commit a30e7c4

Please sign in to comment.