add image picler
This commit is contained in:
parent
3306a34e5c
commit
43a90bccb4
@ -1,6 +1,8 @@
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:image_picker/image_picker.dart';
|
||||
|
||||
import 'DisplayPictureScreen.dart';
|
||||
import 'package:camera/camera.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
@ -63,6 +65,22 @@ class CameraState extends State<Camera> {
|
||||
|
||||
Future<void> getCamera() async {}
|
||||
|
||||
Future<void> pickImage() async {
|
||||
final imagePicker = ImagePicker();
|
||||
final pickedFile = await imagePicker.pickImage(source: ImageSource.gallery);
|
||||
if (pickedFile != null) {
|
||||
await Navigator.of(context).push(
|
||||
MaterialPageRoute(
|
||||
builder: (context) => DisplayPictureScreen(
|
||||
// Pass the automatically generated path to
|
||||
// the DisplayPictureScreen widget.
|
||||
imagePath: pickedFile.path,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// Dispose of the controller when the widget is disposed.
|
||||
@ -95,7 +113,7 @@ class CameraState extends State<Camera> {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: <Widget>[
|
||||
FloatingActionButton(
|
||||
onPressed: () => {},
|
||||
onPressed: pickImage,
|
||||
child: Icon(Icons.photo_library),
|
||||
),
|
||||
SizedBox(width: 40),
|
||||
|
Loading…
x
Reference in New Issue
Block a user