question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Offer more Builders when wrapping widgets

See original GitHub issue

I’d like for the “wrap widget” context menu to offer a greater selection of builders, e.g., AnimatedBuilder and LayoutBuilder.

When it comes to single-child widgets, and even multi-child widgets, it’s easy to select a similar widget and then rename it. For example, if I want a Stack, it’s not available in the context menu, but I can easily select Column and then rename it. However, Builders are not so easily substituted.

Builders have varying additional arguments, e.g., Stream, Listenable, etc. Moreover, the builder delegate signature varies between Builders.

Providing more Builders would be a much bigger time saver for me than having a long list of interchangeable widgets.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:10
  • Comments:17 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
matthew-carrollcommented, May 14, 2021

@pq I guess I missed some of the followup messages here a year ago.

Here are some examples of what I’d expect to see generated for a few different builders:

LayoutBuilder(
  builder: (context, constraints) {
    [CODE_NEEDED]
  },
)
AnimatedBuilder(
  animation: [CODE_NEEDED]
  builder: (context, value) {
    [CODE_NEEDED]
  },
)

And then perhaps support for a “generic builder”, which won’t completely satisfy any builder, but would be a nice headstart for custom builders:

MyBuilder(
  builder: (context) {
    [CODE_NEEDED]
  },
)

I do think this is worth some UX investigation. CC @InMatrix

1reaction
matthew-carrollcommented, May 11, 2020

For me, personally, the structure is all that matters. I haven’t found much value in filling in the name of a widget. Instead, the value is generating the child: line or the children:[] array, or in the case of the builders, the actual builder function.

Builders are the most problematic because most builder functions differ in signature, and on top of that, they all take different required parameters.

I’m not the sure the heuristic of “widgets…most common in user code” is necessarily a good one because the frequency of use doesn’t reflect the tediousness of adding the widget. If you again consider something like LayoutBuilder, I may only use that once in my app, but I’d be far more appreciative of not having to lookup that builder function signature online than I would to have quick access to a Center widget, which only saves me a couple seconds vs the generic “wrap with widget”

PS - I understand that the needs of beginner Flutter developers may be different here. I am transparently saying this as someone who knows most of the widgets that are available.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Flutter Wrap & List.generate | Row & Column Layout - YouTube
You will learn how to use Wrap widget with List.generate to generate dynamic widgets on the fly. You will also learn how to...
Read more >
flutter - How can I improve the performance of Wrap Widget ...
Technically the idea of Wrap.builder wouldn't be a solution here because the issue persists even when all the items are in the displayed ......
Read more >
Wrap Widget & Chip Widgets in Flutter - Vipin Vijayan - Medium
This helps to create a list of Chips to Select from one at a time. Widget choiceChips() { return Expanded( child: ListView.builder( itemCount:...
Read more >
Wrap class - widgets library - Flutter - Dart API docs
API docs for the Wrap class from the widgets library, for the Dart programming ... properties) → void: Add additional properties associated with...
Read more >
Flutter - Wrap Widget - GeeksforGeeks
Wrap widget aligns the widgets in a horizontal and vertical manner. Generally, we use Rows and Columns to do that but if we...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found