'What is Constraint layout's equivalent in Flutter?
Can I position a widget based on another widget? like this:
Tiled Layout Without
flutter_staggered_grid_view Library
Solution 1:[1]
There is no Widget
similar to ConstraintLayout
but you can achieve what you want using different widgets, like this example:
class Testing2 extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
color: Colors.red,
child: Row(
children: <Widget>[
Flexible(
child: Column(
children: <Widget>[
Flexible(
flex: 1,
child: Container(
color: Colors.deepOrange,
),
),
Flexible(
flex: 2,
child: Container(
color: Colors.lightBlue,
),
),
],
),
),
Flexible(
child: Column(
children: <Widget>[
Flexible(
flex: 3,
child: Container(
color: Colors.orange,
)),
Flexible(
flex: 1,
child: Row(
children: <Widget>[
Flexible(
flex: 2,
child: Container(
color: Colors.blue,
)),
Flexible(child: Container(color: Colors.green))
],
),
)
],
),
)
],
),
);
}
Also you can take a look this link to know about Layout Widgets: https://flutter.io/widgets/layout/
Solution 2:[2]
You can try this:
https://github.com/hackware1993/Flutter-ConstraintLayout
Build flexible layouts with constraints, Similar to Android ConstraintLayout.
No matter how complex the layout is and how deep the dependencies are, each child element of ConstraintLayout will only be measured once, This results in extremely high layout performance.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | diegoveloper |
Solution 2 | ??? |