@@ -3,9 +3,7 @@ import 'package:sign_language_translator/components/camera.dart';
33import 'package:sign_language_translator/components/instructions_pop_up.dart' ;
44
55class CameraPage extends StatefulWidget {
6- const CameraPage ({
7- super .key,
8- });
6+ const CameraPage ({super .key});
97
108 @override
119 State <CameraPage > createState () => _CameraPageState ();
@@ -14,6 +12,13 @@ class CameraPage extends StatefulWidget {
1412class _CameraPageState extends State <CameraPage > {
1513 final GlobalKey <CameraState > _cameraKey = GlobalKey <CameraState >();
1614 bool _isTranslating = false ;
15+ String _translation = '' ;
16+
17+ void _updateTranslation (String translation) {
18+ setState (() {
19+ _translation = translation;
20+ });
21+ }
1722
1823 @override
1924 Widget build (BuildContext context) {
@@ -34,7 +39,10 @@ class _CameraPageState extends State<CameraPage> {
3439 const SizedBox (height: 2 ),
3540 Container (
3641 constraints: const BoxConstraints (maxHeight: 400 ),
37- child: Camera (key: _cameraKey),
42+ child: Camera (
43+ key: _cameraKey,
44+ onTranslationReceived: _updateTranslation,
45+ ),
3846 ),
3947 const SizedBox (height: 110 ),
4048 Column (
@@ -46,8 +54,7 @@ class _CameraPageState extends State<CameraPage> {
4654 onPressed: () {
4755 setState (() {
4856 if (_isTranslating) {
49- _cameraKey.currentState
50- ? .stopAndGetTranslation ();
57+ _cameraKey.currentState? .stopAndGetTranslation ();
5158 } else {
5259 _cameraKey.currentState? .startTakingPictures ();
5360 }
@@ -76,9 +83,9 @@ class _CameraPageState extends State<CameraPage> {
7683 padding: const EdgeInsets .symmetric (horizontal: 20 ),
7784 height: 92 ,
7885 alignment: Alignment .center,
79- child: const Text (
80- 'Sign Language Translator' ,
81- style: TextStyle (
86+ child: Text (
87+ _translation.isEmpty ? 'No translation' : _translation ,
88+ style: const TextStyle (
8289 color: Colors .deepPurple,
8390 fontSize: 20 ,
8491 ),
0 commit comments