A custom widget for FlutterFlow that wraps any child widget with a fully customizable dotted or dashed border. FlutterFlow's native Container doesn't support this — this widget fills that gap.
Border styles
Border styles
dashLength: 4 dashGap: 4 radius: 8
dashLength: 8 dashGap: 4 radius: 12
dashLength: 2 dashGap: 2 radius: 0
What's included
Integration
Dependency required
This widget uses the dotted_border package. Add it to your FlutterFlow project before pasting the widget code, otherwise it won't compile.
In FlutterFlow, go to App Settings → Project Dependencies → Add Package. Search for `dotted_border` and add version `^3.1.0`. This is required before the widget will compile.
Go to Custom Code → Custom Widgets → + Create. Name it exactly `DottedBorderContainer`.
Add all 8 parameters from the table below with their correct types and default values.
Paste the full widget code from the section below. Hit Save — FlutterFlow will compile it automatically.
Drop DottedBorderContainer onto your page and pass any child widget into it. Set your border color, dash pattern, and corner radius.
API reference
| Parameter | Type | Default | Description |
|---|---|---|---|
| width | double? | — | Container width |
| height | double? | — | Container height |
| borderColor | Color? | #57636C | Border color |
| strokeWidth | double? | 2.0 | Border line thickness |
| dashLength | double? | 4.0 | Length of each dash segment |
| dashGap | double? | 4.0 | Gap between dash segments |
| borderRadius | double? | 8.0 | Corner radius of the container |
| child | Widget Function()? | — | Any child widget to wrap |
Ready to copy
DottedBorderContainer(
dashLength: 4,
dashGap: 4,
borderRadius: 8,
borderColor: Colors.grey,
strokeWidth: 2,
)DottedBorderContainer(
dashLength: 8,
dashGap: 4,
borderRadius: 12,
borderColor: Colors.orange,
strokeWidth: 2,
)DottedBorderContainer(
dashLength: 2,
dashGap: 2,
borderRadius: 0,
strokeWidth: 1,
)DottedBorderContainer(
dashLength: 6,
dashGap: 3,
borderRadius: 0,
strokeWidth: 3,
borderColor: Colors.black,
)Full source
Copy the entire file into FlutterFlow → Custom Code → Custom Widgets.
// Automatic FlutterFlow imports
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
import '/custom_code/widgets/index.dart'; // Imports other custom widgets
import '/flutter_flow/custom_functions.dart'; // Imports custom functions
import 'package:flutter/material.dart';
// Begin custom widget code
// DO NOT REMOVE OR MODIFY THE CODE ABOVE!
import 'package:dotted_border/dotted_border.dart';
class DottedBorderContainer extends StatelessWidget {
const DottedBorderContainer({
super.key,
this.width,
this.height,
this.child,
this.borderColor,
this.strokeWidth,
this.dashLength,
this.dashGap,
this.borderRadius,
});
final double? width;
final double? height;
final Widget Function()? child;
final Color? borderColor;
final double? strokeWidth;
final double? dashLength;
final double? dashGap;
final double? borderRadius;
@override
Widget build(BuildContext context) {
return SizedBox(
width: width,
height: height,
child: DottedBorder(
options: RoundedRectDottedBorderOptions(
color: borderColor ?? const Color(0xFF57636C),
strokeWidth: strokeWidth ?? 2.0,
dashPattern: [dashLength ?? 4.0, dashGap ?? 4.0],
radius: Radius.circular(borderRadius ?? 8.0),
padding: EdgeInsets.zero,
),
child: Center(
child: child != null ? child!() : const SizedBox.shrink(),
),
),
);
}
}⚖MIT — Free to use in personal and commercial projects.
From the trenches
Add the package first:: The widget won't compile without `dotted_border: ^3.1.0` in your project dependencies — this is step 1, not an afterthought.
Upload zones:: dashLength 4 + dashGap 4 is the classic 'drop file here' pattern — pair it with an upload icon child widget.
Equal dash and gap:: Setting dashLength === dashGap creates perfectly even dashes. Try 6/6 for a balanced look.
Sharp corners:: Set borderRadius: 0 for a rectangular border — great for section separators and dividers.
Free & open source
Drop-in shimmer loading animation. Five layout presets, fully customizable.
Smart text truncation with '...' append. Zero dependencies, pure Dart.
Profile image with initials fallback. Same name always gets the same color.
3D flip animation between front and back content. Tap to reveal.
Building an app?
I build complete apps for founders — fixed prices, fast delivery. Book a free 30-minute call and let's talk about your idea.
Book a free call