From 99e58b7471702386c6c0e3c5589319fa059cc320 Mon Sep 17 00:00:00 2001 From: Ivan Josiel <39556647+ivan07josiel@users.noreply.github.com> Date: Sun, 15 Mar 2020 16:27:21 -0300 Subject: [PATCH] Avoiding negative width When widget.count is 0 the resulting width is negative and throws "BoxConstraints has a minimum negative width.". --- lib/flutter_page_indicator.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/flutter_page_indicator.dart b/lib/flutter_page_indicator.dart index 1ab652c..d9e5638 100644 --- a/lib/flutter_page_indicator.dart +++ b/lib/flutter_page_indicator.dart @@ -243,7 +243,7 @@ class _PageIndicatorState extends State { @override Widget build(BuildContext context) { Widget child = new SizedBox( - width: widget.count * widget.size + (widget.count - 1) * widget.space, + width: widget.count > 0 ? widget.count * widget.size + (widget.count - 1) * widget.space : 0.0, height: widget.size, child: new CustomPaint( painter: _createPainer(),