How to assign different height to each child in a dynamically generated staggered view?

I know staggered view is used for different sized images but when I make an API call to my database, changing the image will change the height for all the images and I want them to have different heights. I already tried this and set it to my height but it didn't work. Any ideas?

int? alternateHeight() {
  /// MODIFY CODE ONLY BELOW THIS LINE
  int count = 0;

  int alternatingNumber() {
    count++;
    return count % 4 == 1 || count % 4 == 0 ? 200 : 300;
  }

  while (true) {
    print(alternatingNumber());
  }

  /// MODIFY CODE ONLY ABOVE THIS LINE
}