From 4837412652f2e2b0a416db789b89f353aa1103aa Mon Sep 17 00:00:00 2001 From: zhangmeng <494089941@qq.com> Date: Tue, 3 Aug 2021 15:20:32 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=20as=20divider?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- example/lib/widgets/example_divider.dart | 28 ++++++++++++++++++------ lib/divider/as_dotted_divider.dart | 4 +++- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/example/lib/widgets/example_divider.dart b/example/lib/widgets/example_divider.dart index b991a8c..800829a 100644 --- a/example/lib/widgets/example_divider.dart +++ b/example/lib/widgets/example_divider.dart @@ -23,8 +23,9 @@ class _ExampleDividerState extends State { color: Colors.red, child: 'ASDivider'.text.make(), ), - ASDivider(color: Colors.black,), - + ASDivider( + color: Colors.black, + ), Row( children: [ Container( @@ -45,12 +46,25 @@ class _ExampleDividerState extends State { color: Colors.red, child: 'ASDottedDivider'.text.make(), ), - ASDottedDivider.horizontal(color: Colors.black,), + ASDottedDivider.horizontal( + color: Colors.black, + ), + Container( - width: double.infinity, - height: 50.w, - color: Colors.red, - child: 'ASDottedDivider'.text.make(), + height: 100.w, + child: Row( + children: [ + Container( + color: Colors.red, + ).expand(), + ASDottedDivider.vertical( + color: Colors.black, + ), + Container( + color: Colors.red, + ).expand(), + ], + ), ), ], ), diff --git a/lib/divider/as_dotted_divider.dart b/lib/divider/as_dotted_divider.dart index 2676be8..0531c33 100644 --- a/lib/divider/as_dotted_divider.dart +++ b/lib/divider/as_dotted_divider.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter/rendering.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; class ASDottedDivider extends StatelessWidget { @@ -37,7 +38,8 @@ class ASDottedDivider extends StatelessWidget { : boxConstraints.constrainHeight(); final _dashWidth = dashWidth ?? 10.w; final _dashPattern = (1 + dash![1] / dash![0]); - final int count = (boxWidth / (_dashWidth * _dashPattern)).floor(); + final int count = + (( boxWidth) / (_dashWidth * _dashPattern)).floor(); return Flex( direction: axis, mainAxisAlignment: MainAxisAlignment.spaceBetween,