Wrap (Flutter Widget of the Week)

Google for Developers · 478K views · 2018 · 0:53

Open on YouTube

Software (other)UX & UI designexplainer

Why Stack Overflow recommends it

Stack Overflow users link it when answering Flutter layout questions about overflowing Rows, wrapping widgets, tag-style grids and the spacing versus runSpacing properties.

Recommended by 6 people across 6 different months, 2019 to 2023.

What it is

A 53-second entry in Google's Flutter Widget of the Week series covering the Wrap widget. It explains that Wrap lays out children like a Row or Column but flows them onto the next line when space runs out, and shows the direction, alignment and spacing properties.

What people said

Recommends KPandian · 2019-04 · Stack Overflow · on “Flutter- wrapping text”

If it's a single text widget that you want to wrap, you can either use Flexible or Expanded widgets. Expanded( child: Text('Some lengthy text for testing'), ) or Flexible( child: Text('Some lengthy text for testing'), ) For multiple widgets, you may choose Wrap widget. For further details checkout this [this video]

Recommends Kherel · 2020-06 · Stack Overflow · on “Flutter different size of gridview item”

use Wrap [this video] [LINK] import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.blue, ), home: Scaffold( body: SafeArea( child: MyHomePage(), ), ), ); } } class MyHomePage extends StatelessWidget { @override Widget build(BuildContext context) { var elements = [ 'Android', 'Ios', 'Web front', 'Sever', 'Embedded Sofware', 'Design' ]; return Wrap( children: elements.map((el) => _MyButton(name: el)).toList(), ); } } class _MyButton extends StatelessWidget { _MyButton({Key key, this.name}) : super(key: key); final S

Recommends Abdullah Khudher · 2021-11 · Stack Overflow · on “Flutter Gridview or StaggeredGridview variable width /variable number of items to fill column”

If these containers are not buttons (mean you don't need to click on each of them to do specific something) then you can use Wrap Widget [this video] [LINK]

Recommends Nilesh Senta · 2022-07 · Stack Overflow · on “what is differencebetween spacing and runSpacing in Flutter Wrap() Widget?”

Widget Wrap spacing means the space between two widget in main axis Widget Wrap runSpacing means the space between two widget in cross axis Check this video. [this video]

Recommends PrzemekTom · 2022-10 · Stack Overflow · on “The equivalent of wrap_content and match_parent in flutter?”

I do agree with all but one cases. `Wrap_content ,Wrap_content` one is handled by design by Flutter (which is great, you don't need to assign no _width_ nor _height_ every time). `Wrap` has different usage, explained here: [this video]

Recommends MendelG · 2023-12 · Stack Overflow · on “How to prevent overflow error for Row widget?”

To prevent an Overflow on your Row widget. Instead of using a Row , use Wrap [LINK] - which wraps the widgets to the next line when there's no space: import 'package:flutter/material.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( body: Wrap( // --> Use Wrap instead of Row children: [ // left panel Container( width: 400, child: Placeholder(), ), // content panel Expanded(child: Placeholder()) ], ), )); } } Here is an official video [this video] by the Flutter team, explaining Wrap .

Cites Farwa · 2019-12 · Stack Overflow · on “The equivalent of wrap_content and match_parent in flutter?”

Use the widget Wrap . For Column like behavior try: return Wrap( direction: Axis.vertical, spacing: 10, children: <Widget>[...],); For Row like behavior try: return Wrap( direction: Axis.horizontal, spacing: 10, children: <Widget>[...],); For more information: Wrap (Flutter Widget) [this video]

Cites hfelpp · 2020-06 · Stack Overflow · on “Making a ListView that expand Horizontally and Vertically”

What you want here is the Wrap widget: [this video] Try something like this: Wrap( spacing: 8.0, children: <Widget> [ TagContainer(name: 'LoreIpsumLoreIpsum'), TagContainer(name: 'LoreIpsum'), TagContainer(name: 'LoreIpsum'), TagContainer(name: 'LoreIpsumLore'), TagContainer(name: 'Lore') ] )

Cites TimeToCode · 2021-10 · Stack Overflow · on “How to use Wrap widget inside column widget in flutter”

I want to display items in a row using wrap widget, my code stack look like this column>padding>wrap and its output is this [LINK] i want them i row like in this tutorial [this video] here is the code: customExpansionTile(context, "Token Distribution Time", true, Icon(Icons.info_rounded, color: HexColor("#5344ed")), <Widget>[ SizedBox10(), Container( // padding: EdgeInsets.only(right: 70), child: Row( children: [ Expanded( child: SizedBox( child: ListTile( //font change title: ListView.builder( itemCount: checkBoxListTileModel.length, itemBuilder: (BuildContext context, int index) { return new Card( child: new Container( padding: new EdgeInsets.all(10.0), child: Column( children: <Widget>[ new Ch

Cites Hesam · 2022-09 · Stack Overflow · on “How to add a background colour to unselected label for a tabbar in flutter”

Based on your case and design, I go with Chips and Wrap [this video] widgets if I want to build your design. Then I have a Container below them that acts as TabBarView. So, you need to change the child of the Container when the user taps on the Chip. However, if you want to stick with TabBar then you need to set a theme when you launch the app. This is how I assign my themes, usually. [LINK]