Skip to content
pubscout

textwrap

2.2.1, released 3 months ago by ykmnkmi.kz

Text wrapping and filling utility library, a pure port of Python's textwrap module.

WASM-ready
$ flutter pub add textwrap
Source repository

What it does

Provides functions and a TextWrapper class for smart text wrapping, paragraph filling, indentation, and text shortening. It handles long words and whitespace according to configurable options.

AI-written summary of version 2.2.1, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to format text for console applications or generated documentation
  • You need to wrap paragraphs to a specific line width with custom indentation
  • You want to shorten long text with a custom placeholder

Skip it when

  • You are doing complex UI text layout that should rely on Flutter's built-in text painting and rendering engine

Strengths

  • Pure Dart implementation with no external dependencies
  • Familiar API for developers coming from Python's textwrap module
  • Supports reusable wrapper configurations via the TextWrapper class

Weaknesses

  • Limited to text manipulation utilities rather than full UI text rendering

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
1
import 'package:textwrap/textwrap.dart';

void main() {
  print(fill('Text wrapping and filling with intelligent line breaks.', width: 16));
}

Alternatives

Packages that do the same job and could replace textwrap.

Works with

Packages commonly used together with textwrap: ones it builds on, ones built on it, and its own family.