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
dart fix
should remove const
s when they err just as it adds them when needed
#49818
Comments
Can you provide a minimal reproduction case in which the diagnostic is reported but |
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: 'Flutter Demo',
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final int counter = 0;
@override
Widget build(BuildContext context) {
return const Scaffold(
body: Center(
child: Text(
'Counter: $counter',
),
),
);
}
}
|
Perfect, thank you! |
For anyone looking at adding such a fix, I'll point out that while the posted example is straightforward (as requested), the semantics of the fix are a bit harder. We'd want to remove
should be converted to
so that the semantics are preserved as much as possible. Also, the fix has to deal with places where
|
Without additional information we're not able to resolve this issue, so it will be closed at this time. You're still free to add more info and respond to any questions above, though. We'll re-open the case if you do. Thanks for your contribution! |
(Note: we recently added a 'no response' bot to our repo; it may have closed existing issues with the |
I don't believe this issue should be closed, and I can't reopen the issue myself, I don't see the option on GitHub. |
https://dart-review.googlesource.com/c/sdk/+/276941 There are possibly other diagnostics to be associated with the Please note that |
dart fix
automatically addsconst
which is great, but if we change some value to be nonconst
, such as in a Flutter widget tree, we get errors. In my opinion,dart fix
should remove thoseconst
s because it knows where the error is already.Dart SDK version: 2.17.6 (stable) (Tue Jul 12 12:54:37 2022 +0200) on "windows_x64"
The text was updated successfully, but these errors were encountered: