Baseflow / octo_image

A multifunctional Flutter image widget
https://baseflow.com/
MIT License
156 stars 23 forks source link

Width and height on image doesn't restrain widgets #8

Closed renefloor closed 4 years ago

renefloor commented 4 years ago

SizedBox around the Image makes sure all provided builders are within the provided height and width

:sparkles: What kind of change does this PR introduce? (Bug fix, feature, docs update...)

:arrow_heading_down: What is the current behavior?

Placeholder and error widgets were not bounded by width and height of the image

:new: What is the new behavior (if this is a feature change)?

Now the whole widget is bound by the width and height given.

:boom: Does this PR introduce a breaking change?

Only for people who want their placeholder and error widgets to be larger than the image itself.

:bug: Recommendations for testing

Easy to test with the frame placeholder, which always takes the maximum size. Previously this placeholder showed full-screen, now it is bound to 150x150:

class TestImage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('OctoImage Demo'),
      ),
      body: Center(
        child: OctoImage(
          image: CachedNetworkImageProvider('https://via.placeholder.com/150'),
          placeholderBuilder: OctoPlaceholder.frame(),
          width: 150,
          height: 150,,
        ),
      ),
    );
  }
}

:memo: Links to relevant issues/docs

Fixes #7

:thinking: Checklist before submitting