How can i switch this code to be displayed on a carousel pro flutter

hello everyone i need help from experts, im a begginer in flutter development. I am trying for like two weeks to display those images into a carousel pro but no luck and i really need your help to move on There are some photos from firestore storage that i want to display in my mobile app its working but i just want to be in a carousel slide.

Thanks for everyones FeedBack!!

class ImagesScreen extends StatelessWidget {
  Widget makeImagesGrid() {
    return GridView.builder(
      itemCount: 7,
        gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
            crossAxisCount: 2),
        itemBuilder: (context, index) {
          return ImageGridItem(index+1);
        });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Test Image"),
      ),
      body: Container(
        child: makeImagesGrid(),
      ),
    );
  }
}

class ImageGridItem extends StatefulWidget {

  int _index;

  ImageGridItem(int index){
    this._index = index;
  }
  @override
  _ImageGridItemState createState() => _ImageGridItemState();
}

class _ImageGridItemState extends State<ImageGridItem> {
  
  Uint8List imageFile;
  StorageReference photosReference = FirebaseStorage.instance.ref().child("images/reklama");
  
  getImage() {
    int MAX_SIZE = 7*1024*1024;
    
    photosReference.child("reklama_${widget._index}.jpg").getData(MAX_SIZE).then((data) {
      this.setState(() {
        imageFile = data;
      });
    }).catchError((error){
      debugPrint(error.toString());
    });
  }
  
  Widget decideGridTileWidget() {
    if(imageFile == null) {
      return Center(child: Image.asset("images/reklama.jpg"));
    }else {
      return Image.memory(imageFile,fit: BoxFit.cover);
    }
  }

  @override
  void initState() {
    super.initState();
    getImage();
  }
  
  @override
  Widget build(BuildContext context) {
    return GridTile(child: decideGridTileWidget());
  }
}


Read more here: https://stackoverflow.com/questions/64414753/how-can-i-switch-this-code-to-be-displayed-on-a-carousel-pro-flutter

Content Attribution

This content was originally published by Simon Gjokaj at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: