RecognitionResultsWidget.dart
2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:speech_to_text/speech_to_text_provider.dart';
/// Show the most recently recognized speech results and use the level
/// information to animate the microphone.
///
/// Note that the provider is initialized elsewhere and just accessed
/// here.
class RecognitionResultsWidget extends StatelessWidget {
const RecognitionResultsWidget({super.key});
@override
Widget build(BuildContext context) {
var speechProvider = Provider.of<SpeechToTextProvider>(context);
return Column(
children: <Widget>[
const Center(
child: Text(
'Recognized Words',
style: TextStyle(fontSize: 22.0),
),
),
Expanded(
child: Stack(
children: <Widget>[
Container(
color: Theme.of(context).secondaryHeaderColor,
child: Center(
child: Text(
speechProvider.lastResult?.recognizedWords ?? '',
textAlign: TextAlign.center,
),
),
),
Positioned.fill(
bottom: 10,
child: Align(
alignment: Alignment.bottomCenter,
child: Container(
width: 40,
height: 40,
alignment: Alignment.center,
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
blurRadius: .26,
spreadRadius: speechProvider.lastLevel * 1.5,
color: Colors.black.withOpacity(.05))
],
color: Colors.white,
borderRadius: const BorderRadius.all(Radius.circular(50)),
),
child: IconButton(
icon: const Icon(Icons.mic),
onPressed: () {},
),
),
),
),
],
),
),
],
);
}
}