|
33 | 33 | 9. percentage layout
|
34 | 34 | 10. guideline
|
35 | 35 | 11. constraints and widgets separation
|
| 36 | +12. barrier |
36 | 37 |
|
37 | 38 | Coming soon:
|
38 | 39 |
|
39 |
| -1. barrier |
40 |
| -2. constraints visualization |
41 |
| -3. chain |
42 |
| -4. dimension ratio |
43 |
| -5. more... |
| 40 | +1. constraints visualization |
| 41 | +2. chain |
| 42 | +3. dimension ratio |
| 43 | +4. more... |
44 | 44 |
|
45 | 45 | Support platform:
|
46 | 46 |
|
@@ -289,11 +289,15 @@ class ExampleState extends State<Example> {
|
289 | 289 | 1. guideline
|
290 | 290 |
|
291 | 291 | ```dart
|
292 |
| -class ExampleState extends State<Example> { |
293 |
| - ConstraintId guideline = ConstraintId(); |
| 292 | +import 'package:flutter/material.dart'; |
| 293 | +import 'package:flutter_constraintlayout/constrait_layout/constraint_layout.dart'; |
| 294 | +
|
| 295 | +class GuidelineExample extends StatelessWidget { |
| 296 | + const GuidelineExample({Key? key}) : super(key: key); |
294 | 297 |
|
295 | 298 | @override
|
296 | 299 | Widget build(BuildContext context) {
|
| 300 | + ConstraintId guideline = ConstraintId(); |
297 | 301 | return MaterialApp(
|
298 | 302 | home: Scaffold(
|
299 | 303 | body: ConstraintLayout(
|
@@ -341,6 +345,74 @@ class ExampleState extends State<Example> {
|
341 | 345 |
|
342 | 346 | 
|
343 | 347 |
|
| 348 | +2. barrier |
| 349 | + |
| 350 | +```dart |
| 351 | +import 'package:flutter/material.dart'; |
| 352 | +import 'package:flutter_constraintlayout/constrait_layout/constraint_layout.dart'; |
| 353 | +
|
| 354 | +class BarrierExample extends StatelessWidget { |
| 355 | + const BarrierExample({Key? key}) : super(key: key); |
| 356 | +
|
| 357 | + @override |
| 358 | + Widget build(BuildContext context) { |
| 359 | + ConstraintId leftChild = ConstraintId(); |
| 360 | + ConstraintId rightChild = ConstraintId(); |
| 361 | + ConstraintId barrier = ConstraintId(); |
| 362 | + return MaterialApp( |
| 363 | + home: Scaffold( |
| 364 | + body: ConstraintLayout( |
| 365 | + debugShowGuideline: true, |
| 366 | + children: [ |
| 367 | + Container( |
| 368 | + color: const Color(0xFF005BBB), |
| 369 | + ).applyConstraint( |
| 370 | + id: leftChild, |
| 371 | + width: 200, |
| 372 | + height: 200, |
| 373 | + top: parent.top, |
| 374 | + left: parent.left, |
| 375 | + ), |
| 376 | + Container( |
| 377 | + color: const Color(0xFFFFD500), |
| 378 | + ).applyConstraint( |
| 379 | + id: rightChild, |
| 380 | + width: 200, |
| 381 | + height: matchConstraint, |
| 382 | + right: parent.right, |
| 383 | + top: parent.top, |
| 384 | + bottom: parent.bottom, |
| 385 | + heightPercent: 0.5, |
| 386 | + verticalBias: 0, |
| 387 | + ), |
| 388 | + Barrier( |
| 389 | + id: barrier, |
| 390 | + direction: BarrierDirection.bottom, |
| 391 | + referencedIds: [leftChild, rightChild], |
| 392 | + ), |
| 393 | + const Text( |
| 394 | + 'Align to barrier', |
| 395 | + style: TextStyle( |
| 396 | + fontSize: 40, |
| 397 | + color: Colors.blue, |
| 398 | + ), |
| 399 | + ).applyConstraint( |
| 400 | + width: wrapContent, |
| 401 | + height: wrapContent, |
| 402 | + centerHorizontalTo: parent, |
| 403 | + top: barrier.bottom, |
| 404 | + goneMargin: const EdgeInsets.only(top: 20), |
| 405 | + ) |
| 406 | + ], |
| 407 | + ), |
| 408 | + ), |
| 409 | + ); |
| 410 | + } |
| 411 | +} |
| 412 | +``` |
| 413 | + |
| 414 | + |
| 415 | + |
344 | 416 | # Support me
|
345 | 417 |
|
346 | 418 | If it helps you a lot, consider sponsoring me a cup of milk tea.
|
|
0 commit comments