Flutter FloatColumn-Widget zum Erstellen einer vertikalen Spalte aus Widgets und Text, wobei der Text um die floatenden Widgets herumfließt, ähnlich wie bei CSS float.
Aus öffentlichen Paketdaten erstellte Orientierung.
Das float_column-Paket bietet ein Flutter-Widget, das vertikale Spaltenlayouts mit Textumfassung um fließende Kind-Widgets ermöglicht und das CSS-Float-Verhalten nachahmt. Es ist ideal für flüssige, magazinartige Layouts, bei denen der Text um Bilder oder andere Elemente herumfließt. Das Widget unterstützt mehrere Plattformen wie Android, iOS, Web, macOS, Windows und Linux und ist daher vielseitig für plattformübergreifende Anwendungen geeignet. Es erhöht die UI-Flexibilität durch Kombination von Layoutgenauigkeit und dynamischer Inhaltsfluss.
Anwendungsfälle
Magazinartige Artikellayouts
Produktlisten mit Bild und Text
Dynamische Inhaltskarten mit schwebenden Elementen
Reaktive Web-Layouts
Soziale Medien-Beitrag wird angezeigt
Hauptmerkmale
Textumbruch um fließende Widgets
Plattformübergreifende Kompatibilität
flexible spaltenbasierte Struktur
Unterschiedliche Widget-Typen werden unterstützt
Einfache Integration in bestehenden Flutter-Code
Geeignet für
UI-Designer, die ein CSS-ähnliches Float-Verhalten benötigen
Entwickler, die inhaltsreiche Apps erstellen
Apps mit responsive Textfluss
Web- und Mobile-Hybridprojekte
Komplexe Layout-Szenarien
Hinweise
Kann sorgfältige Ausrichtungstests erfordern
Leistungsbeeinträchtigung bei vielen floatenden Elementen
Eingeschränkter Support für verschachtelte Fließkommazahlen
Nicht geeignet für hochkomplexe Gittersysteme
Verständnis von Layout-Beschränkungen erforderlich
Original-README
Originaler README-Schnappschuss aus dem verknüpften Quell-Repository. Aktuelle Inhalte finden Sie im Repository.
float_column
A Flutter widget for building a vertical column of widgets and text, where
the text wraps around floated widgets — similar to the CSS float and
clear properties.
Float widgets to the left or right (or start/end for automatic
right-to-left support), with paragraph text wrapping around them.
Float widgets inline from within text using WidgetSpan — the float
anchors to its position in the text.
Clear floats (like CSS clear), with optional minimum spacing.
Margins, padding, and a first-line indent (or hanging indent) on
paragraphs.
Constrain a float's width to a percentage of the column's width.
Full right-to-left text direction support.
Justified text (TextAlign.justify) works correctly, including where
text wraps around floats and at a first-line indent.
Works with Flutter text selection.
FloatColumn widgets can themselves be floated and nested.
Getting started
Add the dependency to your app's pubspec.yaml file:
dependencies:float_column:^4.1.3
And import it:
import'package:float_column/float_column.dart';
Usage
Basic example
FloatColumn accepts a list of children that can be Widget, Text,
RichText, TextSpan, or WrappableText objects. Wrap any widget that
should float in a Floatable:
FloatColumn(
children: [
constFloatable(
float: FCFloat.start,
padding: EdgeInsetsDirectional.only(end: 8),
child: FlutterLogo(size: 100),
),
constFloatable(
float: FCFloat.end,
clear: FCClear.both,
clearMinSpacing: 20,
padding: EdgeInsetsDirectional.only(start: 8),
child: FlutterLogo(size: 100),
),
WrappableText(
text: constTextSpan(
text: 'This text will wrap around the floated widgets, ''flowing to the right of the first logo, then below it, ''then to the left of the second logo…',
),
),
],
),
Plain Text and TextSpan children work too — they're treated like
WrappableText automatically:
FloatColumn(
children: [
constFloatable(float: FCFloat.start, child: FlutterLogo(size: 80)),
constText('Text children wrap around floated siblings too.'),
],
),
Floated widgets in WidgetSpans
Widgets can also be floated from within the text itself by wrapping them
in a Floatable inside a WidgetSpan. The float is anchored to the line
of text containing the WidgetSpan, and the text wraps around it from
there — handy for figures, pull quotes, or margin notes that should stay
with their place in the text:
FloatColumn(
children: [
WrappableText(
text: constTextSpan(
children: [
TextSpan(text: 'The image below is floated at the point in the ''text where it appears'),
WidgetSpan(
child: Floatable(
float: FCFloat.start,
clear: FCClear.start,
padding: EdgeInsetsDirectional.only(end: 8),
maxWidthPercentage: 0.33,
child: Image(image: AssetImage('assets/fig1.png')),
),
),
TextSpan(text: ', and the rest of the paragraph continues to ''wrap around it…'),
],
),
),
],
),
Drop caps
A classic use case — float the first letter of a paragraph:
FloatColumn(
children: [
WrappableText(
text: constTextSpan(
children: [
WidgetSpan(
child: Floatable(
float: FCFloat.start,
padding: EdgeInsetsDirectional.only(end: 8),
child: Text('T', style: TextStyle(fontSize: 64, height: 1)),
),
),
TextSpan(text: 'he rest of the paragraph wraps around the ''oversized first letter, like a drop cap in a book or ''magazine…'),
],
),
),
],
),
See the example app
for a more polished DropCap widget with font-size-aware measurements.
Clearing floats
Like CSS clear, a child can be pushed below previously floated siblings
with the clear property, using FCClear.left, FCClear.right,
FCClear.start, FCClear.end, or FCClear.both. Floated widgets also
support clearMinSpacing, the minimum vertical space between the cleared
widget and the float above it:
FloatColumn(
children: [
constFloatable(float: FCFloat.start, child: FlutterLogo(size: 100)),
constFloatable(
float: FCFloat.start,
clear: FCClear.start, // Placed below the first logo,
clearMinSpacing: 16, // with at least 16 pixels of spacing.
child: FlutterLogo(size: 100),
),
WrappableText(
text: constTextSpan(text: 'This text wraps around both logos…'),
clear: FCClear.none, // The default — no clearing.
),
],
),
Margins, padding, and indent
WrappableText and Floatable both support margin and padding.
Margins can overlap adjacent content, similar to CSS margin behavior —
vertical margins collapse between non-floated siblings, and a floated
child's margin box is what sibling content wraps around. Padding never
overlaps siblings.
WrappableText also supports a first-line indent — use a positive value
for a normal indent or a negative value for a hanging indent:
WrappableText(
text: constTextSpan(text: 'A paragraph with an indented first line…'),
indent: 32,
margin: constEdgeInsetsDirectional.only(start: 16),
padding: constEdgeInsets.symmetric(vertical: 8),
),
Right-to-left text
FloatColumn respects the ambient Directionality (or an explicit
textDirection), and FCFloat.start/FCFloat.end and
FCClear.start/FCClear.end resolve automatically:
Nesting
FloatColumn widgets can be floated and nested:
Reference
Floatable
Property
Description
float
Which side to float to: none (default), left, right, start, or end.
clear
Place this child below floated siblings: none (default), left, right, start, end, or both.
clearMinSpacing
Minimum vertical spacing below the cleared sibling.
margin
Space around the child that can overlap adjacent content.
padding
Space around the child that never overlaps siblings.
maxWidthPercentage
Maximum width as a fraction of the column's width (defaults to 1.0).