Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing Remove this widget case and wrongly removing const #57072

Open
FMorschel opened this issue Nov 12, 2024 · 4 comments
Open

Missing Remove this widget case and wrongly removing const #57072

FMorschel opened this issue Nov 12, 2024 · 4 comments
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@FMorschel
Copy link
Contributor

Repro:

import 'package:flutter/material.dart';

Widget f() {
  return const Center(
    child: Scaffold(
      body: Column(
        children: [
          Text('Hello World!'),
        ],
      ),
    ),
  );
}

Wrongs:

  • If you remove Text the option to Remove this widget is gone from Column
  • At Center you have the option to Remove this widget but it does remove const
@dart-github-bot
Copy link
Collaborator

Summary: The "Remove this widget" feature in Flutter's widget inspector is inconsistent. It disappears when removing a child widget from a Column, and incorrectly removes the const keyword when applied to a Center widget.

@dart-github-bot dart-github-bot added area-front-end Use area-front-end for front end / CFE / kernel format related issues. triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) labels Nov 12, 2024
@devoncarew devoncarew added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. and removed area-front-end Use area-front-end for front end / CFE / kernel format related issues. triage-automation See https://github.com/dart-lang/ecosystem/tree/main/pkgs/sdk_triage_bot. labels Nov 12, 2024
@bwilkerson
Copy link
Member

If you remove Text the option to Remove this widget is gone from Column

How often does this situation arise? I wouldn't think it happens very often, so it doesn't seem like a high priority issue, but if you know differently ...

What should the result be of removing Column in that case? I ask because as a general principle we don't support refactorings / assists when they would produce diagnostics that didn't exist before. Removing Column seems like it would have that characteristic, which probably explains why we don't support it.

At Center you have the option to Remove this widget but it does remove const

That seems like a clear bug.

@FMorschel
Copy link
Contributor Author

With this you also can't remove the Text:

Center(
  child: Text(''),
)

What should the result be of removing Column in that case?

Or the Text in this case.

I would suggest the assist to look if the parameter is positional (not optional) or required to decide this and then if it can be safely removed, simply remove the full parameter.

How often does this situation arise?

I'm not sure. I do get to this some of the time when I have custom widgets in different places on my screen and I'd like to remove it from one of those places.

I wouldn't think it happens very often, so it doesn't seem like a high priority issue

I do agree this is definitely not a high-priority issue. I just think it would be nice to have the assist do this for us. Some of the time there can be lots of inner parameters and this would lessen the job of selecting the full range of lines.

@bwilkerson
Copy link
Member

I just think it would be nice to have the assist do this for us.

I agree, but we need to focus on the higher priority issues first.

@bwilkerson bwilkerson added the P3 A lower priority bug or feature request label Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

4 participants