You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
90 lines
2.8 KiB
90 lines
2.8 KiB
1 year ago
|
import 'dart:convert';
|
||
|
import 'dart:io';
|
||
|
import 'package:flutter/material.dart';
|
||
|
import 'package:flutter/services.dart';
|
||
|
import 'package:healthcare_user/common/settings.dart';
|
||
|
import 'package:image_picker/image_picker.dart';
|
||
|
import 'package:visibility_detector/visibility_detector.dart';
|
||
|
|
||
|
class VideoRecorderPage extends StatefulWidget {
|
||
|
const VideoRecorderPage({Key? key}) : super(key: key);
|
||
|
|
||
|
@override
|
||
|
State<VideoRecorderPage> createState() => _VideoRecorderPageState();
|
||
|
}
|
||
|
|
||
|
class _VideoRecorderPageState extends State<VideoRecorderPage> {
|
||
|
|
||
|
final ImagePicker _picker = ImagePicker();
|
||
|
|
||
|
|
||
|
Future takeVideoFromCamera() async {
|
||
|
try {
|
||
|
final image = await _picker.pickVideo(source: ImageSource.camera);
|
||
|
if (image == null) return;
|
||
|
final imageTemp = File(image.path);
|
||
|
} on PlatformException catch (e) {
|
||
|
print('Failed to pick video: $e');
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return Scaffold(
|
||
|
appBar: AppSettings.appBar('Video recorder'),
|
||
|
body: Container(
|
||
|
child: IconButton(
|
||
|
icon: Icon(
|
||
|
Icons.video_camera_back_rounded,
|
||
|
color: primaryColor,
|
||
|
size: 40,
|
||
|
),
|
||
|
onPressed: () {
|
||
|
showModalBottomSheet<void>(
|
||
|
context: context,
|
||
|
builder: (BuildContext context) {
|
||
|
return SizedBox(
|
||
|
height: 200,
|
||
|
child: Center(
|
||
|
child: Row(
|
||
|
mainAxisAlignment: MainAxisAlignment.center,
|
||
|
children: <Widget>[
|
||
|
GestureDetector(
|
||
|
child: Icon(
|
||
|
Icons.camera_alt_outlined,
|
||
|
size: 100,
|
||
|
color: primaryColor,
|
||
|
),
|
||
|
onTap: () async {
|
||
|
await takeVideoFromCamera();
|
||
|
Navigator.pop(context);
|
||
|
},
|
||
|
),
|
||
|
SizedBox(
|
||
|
width: MediaQuery.of(context).size.width * .20,
|
||
|
),
|
||
|
GestureDetector(
|
||
|
child: Icon(
|
||
|
Icons.photo,
|
||
|
size: 100,
|
||
|
color: primaryColor,
|
||
|
),
|
||
|
onTap: () async {
|
||
|
// await pickVideoFromGallery();
|
||
|
Navigator.pop(context);
|
||
|
},
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
);
|
||
|
});
|
||
|
},
|
||
|
),
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
}
|