Skip to content

Instantly share code, notes, and snippets.

@creativecreatorormaybenot
Last active January 24, 2020 17:44
Show Gist options
  • Save creativecreatorormaybenot/f8474d6f53ee233fa5c57365a14f8d42 to your computer and use it in GitHub Desktop.
Save creativecreatorormaybenot/f8474d6f53ee233fa5c57365a14f8d42 to your computer and use it in GitHub Desktop.
// In RenderCompositedClock (parent layout)
location.layout(constraints, parentUsesSize: true);
// In RenderLocation
_textPainter = TextPainter(...);
_textPainter.layout(maxWidth: constraints.biggest.width); // constraints here are what was given in location.layout
size = _textPainter.size; // size here is the size of the RenderLocation render object
// Back in RenderCompositedClock after laying out the location
locationData.offset = Offset( // Setting the offset positions the child
size.width / 2 - location.size.width / 2, // size here is the size of the whole layout
locationHeight, // Fixed height
);
date.layout(...);
dateData.offset = Offset( // date holds the render object and dateData holds the parent data
size.width / 2 - date.size.width / 2, // Centers the text horizontally
locationData.offset.dy + location.size.height, // Places the date right below the location
);
// Same that I did for date now also happens for the weather.
// Additionally, I supply the size and offset of the weather component to the background,
// so the background curve can react to it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment