-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Camera Widget Implementation #31
base: main
Are you sure you want to change the base?
Changes from 5 commits
29a78eb
d3b75b9
c77569e
09407b1
34c9e48
e48d930
4cf5c57
4943e76
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:imacs/widgets/nav_bar_widget.dart'; | ||
import 'package:imacs/widgets/camera_widget.dart'; | ||
|
||
class CameraScreen extends StatelessWidget { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add doc strings to file, see other files for examples |
||
const CameraScreen({Key? key, required this.title}) : super(key: key); | ||
final String title; | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
title: Text(title), | ||
), | ||
body: CameraWidget(), | ||
bottomNavigationBar: const NavBar()); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:camera_universal/camera_universal.dart'; | ||
|
||
/// Widget to display camera feed | ||
class CameraWidget extends StatefulWidget { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make the doc string more descriptive |
||
final CameraController cameraController = CameraController(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This value is never used, you can remove this and make the constructor const |
||
|
||
CameraWidget({super.key}); | ||
@override | ||
State<CameraWidget> createState() => CameraWidgetState(); | ||
} | ||
|
||
class CameraWidgetState extends State<CameraWidget> { | ||
CameraController cameraController = CameraController(); | ||
@override | ||
void initState() { | ||
super.initState(); | ||
task(); | ||
} | ||
|
||
Future<void> task() async { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rename function to be more descriptive and add doc string |
||
await cameraController.initializeCameras(); | ||
await cameraController.initializeCamera( | ||
setState: setState, | ||
); | ||
await cameraController.activateCamera( | ||
setState: setState, | ||
mounted: () { | ||
return mounted; | ||
}, | ||
); | ||
} | ||
|
||
@override | ||
void dispose() { | ||
cameraController.dispose(); | ||
super.dispose(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
body: Camera( | ||
cameraController: cameraController, | ||
onCameraNotInit: (context) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add log messages to each of the fail states |
||
return const SizedBox.shrink(); | ||
}, | ||
onCameraNotSelect: (context) { | ||
return const SizedBox.shrink(); | ||
}, | ||
onCameraNotActive: (context) { | ||
return const SizedBox.shrink(); | ||
}, | ||
onPlatformNotSupported: (context) { | ||
return const SizedBox.shrink(); | ||
}, | ||
)); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need to complete this file to pass CI/CD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep the logs screen as a placeholder for now