Skip to content

"Remove widget" is not available when it's from a library imported with an alias #4169

@ValentinVignal

Description

@ValentinVignal

Describe the bug

When a library is imported with an alias (ex: import 'package:flutter/material.dart' as material;), the option "Remove widget" is not available on the widget from this library (ex: material.Center()).

To Reproduce
Steps to reproduce the behavior:

  1. Copy this code
import 'package:flutter/material.dart';
import 'package:flutter/material.dart' as material;

class MyWidget extends StatelessWidget {
  const MyWidget({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return const Center(
      child: material.Center(
        child: Text('Flutter'),
      ),
    );
  }
}

Or check out https://github.com/ValentinVignal/flutter_app_stable/tree/flutter-vscode/remove-widget.
2. Toggle the code actions on Center and then on material.Center.
3. Notice that the code action "Remove widget" is available for Center but not for material.Center.

Expected behavior

I expected to be able to remove Center and material.Center

Screenshots

On Center:

image

On material.Center:

image

Please complete the following information:

  • Operating System and version: macOS Big Sur, version 11.6.8
  • VS Code version: 1.71.2
  • Dart extension version: v3.48.4, Flutter extension version: v3.48.0
  • Dart/Flutter SDK version:
Flutter 3.3.2 • channel stable • https://github.com/flutter/flutter.git
Framework • revision e3c29ec00c (8 days ago) • 2022-09-14 08:46:55 -0500
Engine • revision a4ff2c53d8
Tools • Dart 2.18.1 • DevTools 2.15.0
  • Target device (if the issue relates to Flutter debugging): NA

Metadata

Metadata

Assignees

No one assigned

    Labels

    in editorRelates to code editing or language featuresin lsp/analysis serverSomething to be fixed in the Dart analysis serveris bug

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions