Skip to content
Snippets Groups Projects
Commit 6a5c5b54 authored by Thi Huyen Trang Nguyen's avatar Thi Huyen Trang Nguyen
Browse files

KAT-77-TEST: added image_picker in pubspec.yaml

parent c6f9dbe1
No related branches found
No related tags found
No related merge requests found
import 'dart:io';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import '../model/startTriage.dart'; import '../model/startTriage.dart';
import '../enums/start_triage_state.dart'; import '../enums/start_triage_state.dart';
import 'lock_screen.dart'; import 'lock_screen.dart';
...@@ -21,6 +24,21 @@ class CameraAccess extends StatefulWidget { ...@@ -21,6 +24,21 @@ class CameraAccess extends StatefulWidget {
} }
class _CameraAccessState extends State<CameraAccess> { class _CameraAccessState extends State<CameraAccess> {
File _image;
final picker = ImagePicker();
Future getImage() async {
final pickedFile = await picker.getImage(source: ImageSource.camera);
setState(() {
if (pickedFile != null) {
_image = File(pickedFile.path);
} else {
print('');
}
});
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
...@@ -49,13 +67,23 @@ class _CameraAccessState extends State<CameraAccess> { ...@@ -49,13 +67,23 @@ class _CameraAccessState extends State<CameraAccess> {
height: 50, height: 50,
), ),
SizedBox( SizedBox(
height: 250, height: 50,
width: 250, width: 250,
child: RaisedButton( child: RaisedButton(
child: Icon(Icons.photo_library, child: Icon(Icons.photo_library,
color: Colors.black, size: 35), color: Colors.black, size: 35),
color: Colors.grey, color: Colors.white,
onPressed: null), onPressed: getImage),
),
SizedBox(
height: 50,
),
SizedBox(
height: 250,
width: 250,
child: _image == null
? Text('')
: Image.file(_image),
), ),
SizedBox( SizedBox(
height: 50, height: 50,
......
...@@ -23,6 +23,7 @@ environment: ...@@ -23,6 +23,7 @@ environment:
dependencies: dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
image_picker:
# The following adds the Cupertino Icons font to your application. # The following adds the Cupertino Icons font to your application.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment