getCameraWidget method
dynamic
getCameraWidget(
- dynamic param,
- dynamic context
Implementation
getCameraWidget(param, context) {
myLogAll('getCameraWidget');
return SizedBox(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height - 150.0,
child: Scaffold(
//appBar: AppBar(title: const Text('Take a picture')),
// You must wait until the controller is initialized before displaying the
// camera preview. Use a FutureBuilder to display a loading spinner until the
// controller has finished initializing.
body: FutureBuilder<void>(
future: _initializeControllerFuture,
builder: (context, snapshot) {
if (snapshot.connectionState != ConnectionState.done) {
return const Center(child: CircularProgressIndicator());
} else {
return CameraPreview(_cameraController);
}
}),
floatingActionButton: FloatingActionButton(
// Provide an onPressed callback.
onPressed: () async {
// Take the Picture in a try / catch block. If anything goes wrong,
// catch the error.
try {
// Ensure that the camera is initialized.
await _initializeControllerFuture;
// Attempt to take a picture and get the file `image`
// where it was saved.
XFile imageXfile = await _cameraController.takePicture();
File image = File(imageXfile.path);
//var filePath = file.path;
var filename = image.path.split('/').last;
var formname = _mFocusNode[gName];
var item = _mFocusNode[gCol];
var id = _mFocusNode[gId];
var stream = http.ByteStream(image.openRead());
var length = await image.length();
await uploadToServer(
context, filename, stream, length, formname, {gId: item}, id);
//disposeCameraController();
//backContext(_globalLastFocus, context, _globalLastID);
backContext(param, context);
} catch (e) {
e.toString();
}
},
child: const Icon(Icons.camera_alt),
),
),
);
}