File tree Expand file tree Collapse file tree 5 files changed +80
-1
lines changed Expand file tree Collapse file tree 5 files changed +80
-1
lines changed Original file line number Diff line number Diff line change @@ -875,6 +875,43 @@ class CirclePositionExampleState extends State<CirclePositionExample> {
875875}
876876```
877877
878+ 7 . margin [ Flutter Web Online Example] ( https://constraintlayout.flutterfirst.cn )
879+
880+ ![ margin.webp] ( https://github.com/hackware1993/flutter-constraintlayout/blob/master/margin.webp?raw=true )
881+
882+ ``` dart
883+ class MarginExample extends StatelessWidget {
884+ const MarginExample({Key? key}) : super(key: key);
885+
886+ @override
887+ Widget build(BuildContext context) {
888+ return Scaffold(
889+ body: ConstraintLayout(
890+ children: [
891+ Container(
892+ color: const Color(0xFF005BBB),
893+ ).applyConstraint(
894+ size: 50,
895+ topLeftTo: parent,
896+ margin: const EdgeInsets.only(
897+ left: 20,
898+ top: 100,
899+ ),
900+ ),
901+ Container(
902+ color: const Color(0xFFFFD500),
903+ ).applyConstraint(
904+ size: 100,
905+ top: sId(-1).bottom,
906+ right: parent.right.margin(100),
907+ ),
908+ ],
909+ ),
910+ );
911+ }
912+ }
913+ ```
914+
878915# Performance optimization
879916
8809171 . When the layout is complex, if the child elements need to be repainted frequently, it is
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import 'dimension_ratio.dart';
1010import 'grid.dart' ;
1111import 'guideline.dart' ;
1212import 'horizontal_list.dart' ;
13+ import 'margin.dart' ;
1314import 'percentage_layout.dart' ;
1415import 'relative_id.dart' ;
1516import 'self_wrap_content.dart' ;
@@ -37,6 +38,7 @@ class ExampleHome extends StatelessWidget {
3738 'Staggered Grid' : const StaggeredGridExample (),
3839 'Circle Position' : const CirclePositionExample (),
3940 'Self wrapContent' : const SelfWrapContentExample (),
41+ 'Margin' : const MarginExample (),
4042 'Chain (Coming soon)' : const ComingSoonWidget (),
4143 };
4244
Original file line number Diff line number Diff line change 1+ import 'package:flutter/material.dart' ;
2+ import 'package:flutter_constraintlayout/src/constraint_layout.dart' ;
3+
4+ import 'custom_app_bar.dart' ;
5+
6+ class MarginExample extends StatelessWidget {
7+ const MarginExample ({Key ? key}) : super (key: key);
8+
9+ @override
10+ Widget build (BuildContext context) {
11+ return Scaffold (
12+ appBar: const CustomAppBar (
13+ title: 'Margin' ,
14+ codePath: 'example/margin.dart' ,
15+ ),
16+ body: ConstraintLayout (
17+ children: [
18+ Container (
19+ color: const Color (0xFF005BBB ),
20+ ).applyConstraint (
21+ size: 50 ,
22+ topLeftTo: parent,
23+ margin: const EdgeInsets .only (
24+ left: 20 ,
25+ top: 100 ,
26+ ),
27+ ),
28+ Container (
29+ color: const Color (0xFFFFD500 ),
30+ ).applyConstraint (
31+ size: 100 ,
32+ top: sId (- 1 ).bottom,
33+ right: parent.right.margin (100 ),
34+ ),
35+ ],
36+ ),
37+ );
38+ }
39+ }
Original file line number Diff line number Diff line change @@ -36,4 +36,5 @@ flutter:
3636 - example/vertical_list.dart
3737 - example/staggered_grid.dart
3838 - example/circle_position.dart
39- - example/self_wrap_content.dart
39+ - example/self_wrap_content.dart
40+ - example/margin.dart
You can’t perform that action at this time.
0 commit comments