My application is showing only installing but it's not install, I want to implement camera button in my app

import ‘dart:io’;
import ‘dart:async’;
import ‘package:image_picker/image_picker.dart’;
import ‘package:flutter/material.dart’;

void main() => runApp(new MyApp());

class MyApp extends StatefulWidget {
@override
State createState() => new _MyAppState ();
}
class _MyAppState extends State{
File _image;

Future getImage() async {
var image = await ImagePicker.pickImage(source: ImageSource.camera);
setState(() {
_image = image;
});
}

@override
Widget build(BuildContext context) {

return new MaterialApp(title: 'Image Picker',
  home: new Scaffold(
    appBar: new AppBar(title: new Text('Image Picker'),
    ),
    body: new Center(child: _image == null? new Text('No image selected'): new Image.file(_image),
    ),
    floatingActionButton: new FloatingActionButton(onPressed: getImage,tooltip: 'Pick Image',child: new Icon(Icons.camera),),
  ),
);

}

}

and also i added dependencies.

1 Like

Hey! Some more info would help like are you trying this on a real device or emulator?

Sometimes if you have an older version of the App on your phone then Flutter is not able to uninstall it. Try uninstalling any existing instance of the App and install again.

Also, it’s always good to r run flutter clean every now and then. :slight_smile:

I am trying this on a real device, i applied what you suggested but it’s not working yet…

okay, could you please tell the Android version of your device?

Also, is it showing any kind of error on logs?

Android version is 9 and there is no error message only showing installing.

Okay, Please share your code snippet.

/* I am pasting my main.dart code , Now i am facing issue when i am using source camera, it’s working when we use source gallery but after clicking a picture with camera it’s not returning image File.

import ‘package:flutter/material.dart’;
import ‘dart:io’;
import ‘package:image_picker/image_picker.dart’;

void main() => runApp(MyApp());

class MyApp extends StatefulWidget{

@override
State createState() {
return _MyAppState();
}

}

class _MyAppState extends State{

File _image;

Future getImage(bool isCamera) async {

File image;

if(isCamera){
  image = await ImagePicker.pickImage(source: ImageSource.camera);
}else {
  image = await ImagePicker.pickImage(source: ImageSource.gallery);
}

setState(() {
debugPrint(‘inside setState’);
_image = image;
});
}

@override
Widget build(BuildContext context) {

return MaterialApp(
  home: Scaffold(
    appBar: AppBar(
      title: Text('Image Picker'),
    ),
    body: Center(
      child: Column(
        children: <Widget>[
          IconButton(
            icon: Icon(Icons.insert_drive_file),
            onPressed: (){
            getImage(false);
            },
          ),
          SizedBox(height: 10.0),
          IconButton(
            icon: Icon(Icons.camera_alt),
            onPressed: (){
            getImage(true);
            },
          ),
          _image == null? Container() : Image.file(_image,height: 300.0,width: 300.0,),
        ],
      ),
    ),
  ),
);

}
}

Good to hear that you were able to install the Application on your phone. Do share here how you were able to resolve the install issue so that other members can also take help.

On that time i was upgraded my dependencies, but now again i am facing same issue in another project .

it’s only showing installing .