@@ -82,12 +82,12 @@ dependencies:
8282 flutter_constraintlayout :
8383 git :
8484 url : ' https://github.com/hackware1993/Flutter-ConstraintLayout.git'
85- ref : ' v0.9.17 -stable'
85+ ref : ' v0.9.18 -stable'
8686` ` `
8787
8888` ` ` yaml
8989dependencies :
90- flutter_constraintlayout : ^0.9.17 -stable
90+ flutter_constraintlayout : ^0.9.18 -stable
9191` ` `
9292
9393` ` ` dart
@@ -567,6 +567,65 @@ class OffBuildExample extends StatelessWidget {
567567 wrapContent will be re-layout. And since the constraints passed to other child elements won't
568568 change, no real re-layout will be triggered.
569569
570+ 4 . If you use Guideline or Barrier in the children list, Element and RenderObject will inevitably be
571+ generated for them, which will be laid out but not drawn. At this point you can use
572+ GuidelineDefine or BarrierDefine to optimize it, no Element and RenderObject will be generated
573+ anymore:
574+
575+ ``` dart
576+ class BarrierExample extends StatelessWidget {
577+ const BarrierExample({Key? key}) : super(key: key);
578+
579+ @override
580+ Widget build(BuildContext context) {
581+ ConstraintId leftChild = ConstraintId('leftChild');
582+ ConstraintId rightChild = ConstraintId('rightChild');
583+ ConstraintId barrier = ConstraintId('barrier');
584+ return Scaffold(
585+ body: ConstraintLayout(
586+ childConstraints: [
587+ BarrierDefine(
588+ id: barrier,
589+ direction: BarrierDirection.bottom,
590+ referencedIds: [leftChild, rightChild],
591+ ),
592+ ],
593+ children: [
594+ Container(
595+ color: const Color(0xFF005BBB),
596+ ).applyConstraint(
597+ id: leftChild,
598+ width: 200,
599+ height: 200,
600+ topLeftTo: parent,
601+ ),
602+ Container(
603+ color: const Color(0xFFFFD500),
604+ ).applyConstraint(
605+ id: rightChild,
606+ width: 200,
607+ height: matchConstraint,
608+ centerRightTo: parent,
609+ heightPercent: 0.5,
610+ verticalBias: 0,
611+ ),
612+ const Text(
613+ 'Align to barrier',
614+ style: TextStyle(
615+ fontSize: 40,
616+ color: Colors.blue,
617+ ),
618+ ).applyConstraint(
619+ centerHorizontalTo: parent,
620+ top: barrier.bottom,
621+ )
622+ ],
623+ ),
624+ );
625+ }
626+ }
627+ ```
628+
570629# Support me
571630
572631If it helps you a lot, consider sponsoring me a cup of milk tea.
0 commit comments