Title: Insert an image StaggeredGridView that is upload by the user !! The argument type 'File' can't be assigned to the parameter type 'String'
Tags: string;image;file;flutter;staggered-gridview
Question: I want to create a StaggeredGridView and fill it with images that the user uploads. The problem is that the type of StaggeredGridView is String or ```ImageProvider<Object&gt;``` and the file is ```PickedFile``` or File
What is the solution ??
```class GalleryClassOneState extends State<GalleryClassOne&gt; {
  List<File&gt; arrayImage = [];
  File sampleImage;
  final _picker = ImagePicker();

  // @override
  // void initState() {
  //   super.initState();
  //   DatabaseReference images =
  //       FirebaseDatabase.instance.reference().child(&quot;NeuralNetwork&quot;);
  // }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Galeria clase 1'),
      ),
      body: Container(padding: EdgeInsets.all(8), child: galeria(arrayImage)),
      floatingActionButton: FloatingActionButton(
        onPressed: _optionsDialogBox,
        tooltip: 'Pick Image',
        child: Icon(Icons.add_outlined),
      ),
    );
  }


  Widget galeria(List<File&gt; arrayImage) {
    return StaggeredGridView.countBuilder(
      crossAxisCount: 4,
      itemCount: 11,
      itemBuilder: (BuildContext context, int index) {
        return ClipRRect(
          borderRadius: BorderRadius.circular(10),
          child: Container(
            color: Colors.deepPurple,
            child: Column(
              children: <Widget&gt;[
                Image.network(arrayImage[index])
              ],
            ),
          ),
        );
      },
      // staggeredTileBuilder: (int index) =&gt; new StaggeredTile.fit(1),
      staggeredTileBuilder: (int index) =&gt;
          new StaggeredTile.count(2, index.isEven ? 2 : 1),
      mainAxisSpacing: 10.0,
      crossAxisSpacing: 10.0,
    );
  }
}
```



Here is another answer: We will need to work with the images as bytes instead of files. First, make ```arrayImage``` a ```List<Uint8List&gt;```. Here we will store a list of the byte arrays representing an image loaded in memory. Update the ```galeria()``` method to accept a ```List<Uint8List&gt;``` as well.
Now in the ```optionsDialogBox()``` method, we will use the results of the ```_picker``` like so:
```_picker.getImage(source: ImageSource.gallery).then((pickedFile) {
  // read the bytes from the PickedFile
  pickedFile.readAsBytes().then((bytes) {
    // add the image as bytes to the arrayImage list and update the UI
    setState(() =&gt; arrayImage.add(bytes));
  });
});
```
When we create our ```Image``` widget, we will use the ```Image.memory()``` constructor passing to it the bytes representing our image.
```Image.memory(arrayImage[index])
```


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2020:00:11/18/20', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<string><image><file><flutter><staggered-gridview>', 'Title': "Insert an image StaggeredGridView that is upload by the user !! The argument type 'File' can't be assigned to the parameter type 'String'", 'ViewCount': 89, 'id': 64900534, 'user_AboutMe': None, 'user_AccountId': 18003676.0, 'user_DisplayName': 'Joan Codinach Ortiz', 'user_Reputation': 361.0, 'user_Views': 18.0, 'user_id': 13181371.0}}