Skip to content

extract widget refactoring should use super-parameters where possible #49556

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

Closed
pq opened this issue Jul 28, 2022 · 3 comments
Closed

extract widget refactoring should use super-parameters where possible #49556

pq opened this issue Jul 28, 2022 · 3 comments
Assignees
Labels
devexp-linter Issues with the analyzer's support for the linter package devexp-refactoring Issues with analysis server refactorings legacy-area-analyzer Use area-devexp instead. P3 A lower priority bug or feature request

Comments

@pq
Copy link
Member

pq commented Jul 28, 2022

Extracting the Text widget here

class TestWidget extends StatelessWidget {
  const TestWidget({super.key});
  @override
  Widget build(BuildContext context) {
    return const Text('hi');
  }
}

yields

class TestWidget extends StatelessWidget {
  const TestWidget({super.key});
  @override
  Widget build(BuildContext context) {
    return NewWidget();
  }
}

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

  @override
  Widget build(BuildContext context) {
    return const Text('hi');
  }
}

but should produce:

class TestWidget extends StatelessWidget {
  const TestWidget({super.key});
  @override
  Widget build(BuildContext context) {
    return NewWidget();
  }
}

class NewWidget extends StatelessWidget {
  const NewWidget({
    super.key,
  });

  @override
  Widget build(BuildContext context) {
    return const Text('hi');
  }
}

if (at least) use_super_parameters is enabled.

Open question: and possibly just if the feature is available?

@pq pq added legacy-area-analyzer Use area-devexp instead. P3 A lower priority bug or feature request devexp-refactoring Issues with analysis server refactorings devexp-linter Issues with the analyzer's support for the linter package labels Jul 28, 2022
@pq pq self-assigned this Jul 28, 2022
@bwilkerson
Copy link
Member

I don't know what you mean by "available" or how that differs from "enabled", but I suspect that "enabled" is the correct thing to check.

@pq
Copy link
Member Author

pq commented Jul 28, 2022

By available I was thinking of checking the SDK lower-bound but I think enabled is right. Thanks!

@bwilkerson
Copy link
Member

Yes, you want to check enabled. A library can opt out of a feature while still having a lower bound that allows the feature to be used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
devexp-linter Issues with the analyzer's support for the linter package devexp-refactoring Issues with analysis server refactorings legacy-area-analyzer Use area-devexp instead. P3 A lower priority bug or feature request
Projects
None yet
Development

No branches or pull requests

3 participants
@pq @bwilkerson and others