Created
May 6, 2020 14:42
-
-
Save letsar/69952dcc130d00e9c6bd272850ee83a2 to your computer and use it in GitHub Desktop.
RenderGap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class _RenderGap extends RenderBox { | |
_RenderGap({ | |
double mainAxisExtent, | |
}) : _mainAxisExtent = mainAxisExtent; | |
double get mainAxisExtent => _mainAxisExtent; | |
double _mainAxisExtent; | |
set mainAxisExtent(double value) { | |
if (_mainAxisExtent != value) { | |
_mainAxisExtent = value; | |
markNeedsLayout(); | |
} | |
} | |
@override | |
void performLayout() { | |
final AbstractNode flex = parent; | |
if (flex is RenderFlex) { | |
if (flex.direction == Axis.horizontal) { | |
size = constraints.constrain(Size(mainAxisExtent, 0)); | |
} else { | |
size = constraints.constrain(Size(0, mainAxisExtent)); | |
} | |
} else { | |
throw FlutterError( | |
'A Gap widget must be placed directly inside a Flex widget', | |
); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment