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 createState() => _VideoRecorderPageState(); } class _VideoRecorderPageState extends State { 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( context: context, builder: (BuildContext context) { return SizedBox( height: 200, child: Center( child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ 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); }, ), ], ), ), ); }); }, ), ), ); } }