FlutterFever Studio
Back to packages

Float Column Flutter package guide

A Flutter widget that mimics CSS float, letting text wrap around vertically stacked children.

Install command
Copy and run in your Flutter project
flutter pub add float_column

When to use Float Column

The **FloatColumn** widget brings a familiar web‑style layout technique to Flutter: floating elements inside a vertical column while surrounding text flows naturally around them. Instead of the traditional `Column` where each child occupies the full width, FloatColumn allows you to place an image, icon, or any widget on the left or right side of a paragraph and have the remaining text wrap as if it were a floated element in HTML. This makes it easy to create magazine‑style articles, product descriptions with inline images, or any UI where you need a tight coupling between media and prose.

When building rich content screens, developers often resort to complex `Row`/`Wrap` combinations, manual `RichText` spans, or custom layout builders to achieve a floating effect. FloatColumn abstracts that boilerplate into a single, declarative widget. You simply provide a list of children, each optionally marked with a `float` direction (`left` or `right`) and a `widthFactor` that determines how much horizontal space the floated widget consumes. The remaining space is automatically filled with the surrounding `Text` widgets, preserving line‑breaks and respecting the current `TextDirection`. This approach works seamlessly with Flutter's theming, accessibility, and layout constraints, allowing you to keep your UI code clean and maintainable.

The widget shines in scenarios where content is driven by a CMS or markdown source. Imagine a news app that receives article bodies with embedded images. By converting those images into `FloatColumn` children, you can render the article with minimal effort while preserving the original editorial intent. FloatColumn also integrates well with responsive designs: on narrow screens you can switch the `float` direction to `none` or adjust the `widthFactor` so that the floated widget stacks above the text, ensuring a graceful degradation on mobile devices. Because FloatColumn is just a widget, it can be placed anywhere in your widget tree—inside `Scaffold`, `CustomScrollView`, or even inside a `ListView.builder` for infinite scrolling feeds.

Setting up FloatColumn is straightforward. After adding the dependency, import the package and replace any existing `Column` that needs floating behavior with `FloatColumn`. The widget respects all standard layout constraints, so you can combine it with `Expanded`, `Flexible`, or `IntrinsicHeight` as needed. For production use, keep an eye on the widget's performance when dealing with very long texts; the internal layout algorithm runs in O(n) time relative to the number of children, which is negligible for typical article lengths but could become noticeable in extreme cases. Profiling with Flutter DevTools is recommended if you plan to render thousands of floated elements in a single frame.

For beginners, FloatColumn offers a gentle learning curve. The API mirrors familiar Flutter patterns: you pass a `children` list, optionally wrap each child in a `FloatItem` to specify its float direction and width, and let the widget handle the rest. No custom render objects or manual size calculations are required. This makes it an ideal first step for developers transitioning from web development who miss the convenience of CSS floats, as well as for seasoned Flutter engineers looking to reduce layout boilerplate. Whether you are building a blog reader, an e‑commerce product page, or a documentation viewer, FloatColumn provides a clean, declarative way to achieve sophisticated text‑wrap layouts without sacrificing performance or code readability.

article pages with inline images
product descriptions with side‑by‑side media
markdown rendering with floated elements
responsive layouts that adapt float direction on small screens
rich text editors that need image anchoring

Pros

  • declarative API for complex text‑wrap layouts
  • works across all Flutter platforms
  • no custom render objects needed
  • responsive‑friendly with adjustable widthFactor
  • compatible with existing theming and accessibility

Watch outs

  • layout cost grows with number of floated children
  • not a replacement for full‑featured rich‑text editors
  • limited to vertical column orientation

Setup notes

Add the package to your project with: ``` flutter pub add float_column ``` Then import it: ```dart import 'package:float_column/float_column.dart'; ```

FloatColumn works with Flutter 3.0 and later. It relies on the standard rendering pipeline, so it is compatible with mobile (iOS, Android), web, and desktop (Windows, macOS, Linux). No additional platform-specific setup is required.

```dart
import 'package:flutter/material.dart';
import 'package:float_column/float_column.dart';

class ArticlePage extends StatelessWidget {
  const ArticlePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('FloatColumn Demo')),
      body: Padding(
        padding: const EdgeInsets.all(16.0),
        child: FloatColumn(
          children: [
            FloatItem(
              float: FloatDirection.left,
              widthFactor: 0.35,
              child: Image.network(
                'https://example.com/cover.jpg',
                fit: BoxFit.cover,
              ),
            ),
            const Text(
              'Lorem ipsum dolor sit amet, consectetur adipiscing elit. '
              'Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. '
              'Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris '
              'nisi ut aliquip ex ea commodo consequat.',
            ),
          ],
        ),
      ),
    );
  }
}
```

Official package resources