title: how can i add an image in the signup form
body: <p>When i try to open the signup page and signup a new user i am getting this exception:error cannot open file. because of the picked image file but i have the file on my laptop and that is it's current path and when i try to leave it without initialization i am getting an error that it didn't get initialized even if  put late on it or the ? mark and i tried to put a link to the image from google and i got an exception:no such file or directory so what should i do
  that is the authform file:</p>
  <pre><code>
  class Authform extends StatefulWidget {
    final void Function(String email, String password, String username,
        bool islogin, BuildContext ctx) submitfun;
    final bool isloading;
  
    Authform(this.submitfun, this.isloading);
  
    @override
    Authformstate createState() =&gt; Authformstate();
  }
  
  class Authformstate extends State&lt;Authform&gt; {
    final formkey = GlobalKey&lt;FormState&gt;();
    bool islogin = true;
    String email = &quot;&quot;;
    String password = &quot;&quot;;
    String username = &quot;&quot;;
    void pickimage(File pickedimage) {}
  
    void submit() {
      final isvalid = formkey.currentState!.validate();
      FocusScope.of(context).unfocus();
  
      if (isvalid) {
        formkey.currentState!.save();
        widget.submitfun(
            email.trim(), password.trim(), username.trim(), islogin, context);
      }
    }
  
    @override
    Widget build(BuildContext context) {
      return Center(
        child: Card(
          margin: EdgeInsets.all(20),
          child: SingleChildScrollView(
              padding: EdgeInsets.all(16),
              child: Form(
                key: formkey,
                child: Column(
                  mainAxisSize: MainAxisSize.min,
                  children: [
                    if (!islogin) Userimagepicker(pickimage),
                    TextFormField(
                      key: ValueKey('email'),
                      validator: (val) {
                        if (val!.isEmpty || !val.contains('@')) {
                          return &quot;please enter a valid email address&quot;;
                        }
                      },
                      onSaved: (val) =&gt; email = val!,
                      keyboardType: TextInputType.emailAddress,
                      decoration: InputDecoration(labelText: 'email address'),
                    ),
                    if (!islogin)
                      TextFormField(
                        key: ValueKey('username'),
                        validator: (val) {
                          if (val!.isEmpty || val.length &lt; 4) {
                            return &quot;please enter a valid username&quot;;
                          }
                        },
                        onSaved: (val) =&gt; username = val!,
                        decoration: InputDecoration(labelText: 'username'),
                      ),
                    TextFormField(
                      key: ValueKey('password'),
                      validator: (val) {
                        if (val!.isEmpty || val.length &lt; 7) {
                          return &quot;please enter a valid password&quot;;
                        }
                      },
                      onSaved: (val) =&gt; password = val!,
                      decoration: InputDecoration(labelText: 'password'),
                      obscureText: true,
                    ),
                    SizedBox(height: 20),
                    if (widget.isloading) CircularProgressIndicator(),
                    if (!widget.isloading)
                      ElevatedButton(
                          onPressed: submit,
                          child: Text(islogin ? 'login' : 'signup')),
                    if (!widget.isloading)
                      TextButton(
                          onPressed: () {
                            setState(() {
                              islogin = !islogin;
                            });
                          },
                          child: Text(islogin
                              ? 'create new account'
                              : 'i already have an account'),
                          style: TextButton.styleFrom(
                              textStyle: TextStyle(
                                  color: Theme.of(context).primaryColor)))
                  ],
                ),
              )),
        ),
      );
    }
  }
  
  </code></pre>
  <p>and that is the imagepicker file:</p>
  <pre><code>
  class Userimagepicker extends StatefulWidget {
   final void Function(File pickedimage) imagepickfun;
  
   Userimagepicker(this.imagepickfun);
   @override
   UserimagepickerState createState() =&gt; UserimagepickerState();
  }
  
  class UserimagepickerState extends State&lt;Userimagepicker&gt; {
   File pickedimage =
       File('C:\Users\georgederderian\Desktop\whatsapp image.jpg');
  
   final ImagePicker picker = ImagePicker();
  
   void pickimage(ImageSource src) async {
     final pickedimagefile = await picker.pickImage(source: src);
     if (pickedimagefile != null) {
       setState(() {
         pickedimage = File(pickedimagefile.path);
       });
       widget.imagepickfun(pickedimage);
     } else {
       print('no image selected');
     }
   }
  
   @override
   Widget build(BuildContext context) {
     return Column(
       children: &lt;Widget&gt;[
         CircleAvatar(
           radius: 40,
           backgroundColor: Colors.grey,
           backgroundImage: FileImage(pickedimage),
         ),
         SizedBox(height: 10),
         Row(
           mainAxisAlignment: MainAxisAlignment.spaceAround,
           children: [
             TextButton.icon(
               onPressed: () =&gt; pickimage(ImageSource.camera),
               icon: Icon(Icons.photo_camera_outlined),
               label: Text(
                 'add image\n from camera',
                 textAlign: TextAlign.center,
               ),
             ),
             TextButton.icon(
                 onPressed: () =&gt; pickimage(ImageSource.gallery),
                 icon: Icon(Icons.photo_album_outlined),
                 label: Text(
                   'add image\n from gallery',
                   textAlign: TextAlign.center,
                 ))
           ],
         )
       ],
     );
   }
  }
  
  
  </code></pre>