Skip to content

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

Closed

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

Activity

  1. DanTup commented on Sep 22, 2022

    @DanTup
    Member

    Fixed by dart-lang/sdk@3e9a99d. The change is in the Dart SDK, so the fix will show up with a future SDK release (rather than a VS Code extension release).

  2. added
    in editorRelates to code editing or language features
    in lsp/analysis serverSomething to be fixed in the Dart analysis server
    on Sep 22, 2022
  3. added this to the v3.50.0 milestone on Sep 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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