Closed Hauglid closed 2 years ago
Amazing! Thanks a bunch
Amazing! Thanks a bunch
No problem. Thanks for the suggestion, @Hauglid !
Version v0.1.8
should now contain these changes and is available in the VSCode Marketplace:
https://marketplace.visualstudio.com/items?itemName=gmlewis-vscode.flutter-stylizer
I tried this now, and it doesn't sort the variables. I tried with both true and false.
Please copy/paste your config settings for this plugin here so we can figure out the problem.
You need to add the new groupAndSortVariableTypes: true
as described in the readme for this to take effect.
It is important that this plugin continues to behave the same way as it did previously for other people which is why we need to add new flags when new behaviors are requested. I hope that makes sense.
Yes, I understand the need for the flags.
This is the settings I have:
"flutterStylizer": {
"groupAndSortGetterMethods": false,
"groupAndSortVariableTypes": true,
"memberOrdering": [
"public-constructor",
"named-constructors",
"public-static-variables",
"public-instance-variables",
"public-override-variables",
"private-static-variables",
"private-instance-variables",
"public-other-methods",
"public-override-methods",
"private-other-methods",
"build-method"
],
"sortOtherMethods": true
},
So I think I figured it out. Is the formatter only for Stateful/StatelessWidget?
I have a file claim.dart with class Claim extends Equatable
where it doesn't work.
Edit: It works on some widgets, but not all of them for some weird reason
I will try to make a minimal, reproducible example later today.
Yikes... sounds like a bug!
I will try to make a minimal, reproducible example later today.
Fantastic, thank you! I'll work on fixing the bug when I get an example case.
Hey @Hauglid were you able to create the example?
I'm looking forward to using this feature as well 🤗
Hi. Sorry, not yet. Been busy at work. I will try to get it done soon.
Here is a model class with a lot of different variables types. I couple of things I noticed is that private vars and final are sorted by name, not type and name. I would guess that this is the same for static and const?
// ignore_for_file: unused_field
class User {
User({
required this.firstNameFinal,
required this.idFinal,
required this.lastNameFinal,
required this.middleNameFinal,
required this.phoneNumberFinal,
required this.usernameFinal,
required this.firstNameRegular,
required this.idRegular,
required this.lastNameRegular,
required this.usernameRegular,
});
final String firstNameFinal;
final int idFinal;
final String lastNameFinal;
final String? middleNameFinal;
final String? phoneNumberFinal;
final String usernameFinal;
String firstNameRegular;
int idRegular;
String lastNameRegular;
String usernameRegular;
int? ageOptional;
String? birthdateOptional;
String? emailOptional;
String? middleNameRegular;
String? phoneNumberRegular;
int? _agePrivate;
String? _birthdatePrivate;
String? _emailPrivate;
final String _firstNamePrivate = 'Secret';
final int _idPrivate = 0;
final String _lastNamePrivate = 'Secret';
String? _middleNamePrivate;
final String _phoneNumberPrivate = 'Secret';
final String _usernamePrivate = 'Secret';
}
Ah! I get it now. Thank you for the example, @Hauglid ... that helps tremendously. I'll add support for the private vars as well.
@Hauglid - please try out release v0.1.16
of the VS Code plugin when you get a chance and let me know if it fixes the issue for you. Thank you for your patience!
Great work! It seems to be working as intended now 💯
Is your feature request related to a problem? Please describe. Variables are grouped, but I would much more prefer to group optionals, finals, normal vars.
Describe the solution you'd like Separate different type of variables.
Example: How it is today:
How I would prefer it to be: