All widgets
Widget

Dotted Border Container

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.

FlutterDartFlutterFlow
View on GitHub

Border styles

Border styles

↑ upload

dashLength: 4 dashGap: 4 radius: 8

card

dashLength: 8 dashGap: 4 radius: 12

tight

dashLength: 2 dashGap: 2 radius: 0

What's included

Features

  • Dotted & dashed borders — FlutterFlow's native Container can't do this
  • 🎨Fully customizable — color, stroke width, dash length, gap, corner radius
  • 📦Accepts any child widget via FlutterFlow's WidgetBuilder
  • 🔧Uses the popular dotted_border package — production-ready, no hacks
  • 📐Supports sharp and rounded corners (borderRadius: 0 to any value)
  • 🚀Production-ready — used in real FlutterFlow projects

Integration

How to use it

⚠️

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.

How to add:App Settings → Project Dependencies → Add Package → dotted_border: ^3.1.0
1

Add the dependency

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.

2

Create a Custom Widget

Go to Custom Code → Custom Widgets → + Create. Name it exactly `DottedBorderContainer`.

3

Add the parameters

Add all 8 parameters from the table below with their correct types and default values.

4

Paste the code & compile

Paste the full widget code from the section below. Hit Save — FlutterFlow will compile it automatically.

5

Wrap any widget

Drop DottedBorderContainer onto your page and pass any child widget into it. Set your border color, dash pattern, and corner radius.

API reference

Parameters

ParameterTypeDefaultDescription
widthdouble?Container width
heightdouble?Container height
borderColorColor?#57636CBorder color
strokeWidthdouble?2.0Border line thickness
dashLengthdouble?4.0Length of each dash segment
dashGapdouble?4.0Gap between dash segments
borderRadiusdouble?8.0Corner radius of the container
childWidget Function()?Any child widget to wrap

Ready to copy

Preset examples

Upload / Drop Zone

dart
DottedBorderContainer(
  dashLength: 4,
  dashGap: 4,
  borderRadius: 8,
  borderColor: Colors.grey,
  strokeWidth: 2,
)

Dashed Card Border

dart
DottedBorderContainer(
  dashLength: 8,
  dashGap: 4,
  borderRadius: 12,
  borderColor: Colors.orange,
  strokeWidth: 2,
)

Tight Dotted Line

dart
DottedBorderContainer(
  dashLength: 2,
  dashGap: 2,
  borderRadius: 0,
  strokeWidth: 1,
)

Bold Section Divider

dart
DottedBorderContainer(
  dashLength: 6,
  dashGap: 3,
  borderRadius: 0,
  strokeWidth: 3,
  borderColor: Colors.black,
)

Full source

Full widget code

Copy the entire file into FlutterFlow → Custom Code → Custom Widgets.

dart
// 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

Pro tips

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.

Building an app?

Need a full MVP, not just widgets?

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