Prelude
I'm familiar with the dictum
"Constraints go down. Sizes go up. Parent sets position.'
What I'd like to understand is how "constraints" are defined. Is it just a range ("height must be between 30 and infinity"), or is there something more elaborate? Surely I can find the answer from reading Flutter's code, but I'm not yet at that stage.
A concrete answer addressing a very specific example is much more helpful than hand-waving. Hence in an effort to avoid vague answers, please address the following concrete example.
Question
Why does uncommenting the commented-out line trigger an error?import 'package:flutter/material.dart';
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
// crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Text('Hello),
Text('World),
]),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('How),
Text('are you?),
]),
]
);
}
}
Clarification
The following is another way of asking the question.
In the three part:
- "Constraints go down."
- "Sizes go up."
- "Parent sets position."
it's clear what "size" is. It is the Size
class.
It's also clear what "position" is. There is also a class for that (Offset
).
- Is this the class that captures a "constraint"? Is it visible from the programmer side?
- How does the instance of that class change when we uncomment the commented-out line (thereby triggering the error)?