Convert to StatefulWidget does not work on widgets with a Generic.
See original GitHub issueSteps to Reproduce
Performing the quick-action whilst hovering over StatelessWidget
in the following example will offer you to “Convert to StatefulWidget >”.
class HelloWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const Text('world');
}
}
However in this example with the Generic T we loose that quick-action option.
class HelloWidget<T> extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const Text('world');
}
}
Version info
[√] Flutter (Channel dev, v1.10.14, on Microsoft Windows [Version 10.0.17763.805], locale en-GB)
• Flutter version 1.10.14 at C:\Android\flutter
• Framework revision 1946fc4da0 (3 weeks ago), 2019-10-07 15:23:31 -0700
• Engine revision 1d62160fdb
• Dart version 2.6.0 (build 2.6.0-dev.5.0 d6c6d12ebf)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at C:\Android\SDK
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• ANDROID_HOME = C:\Android\SDK
• Java binary at: C:\Android\Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
[√] Android Studio (version 3.5)
• Android Studio at C:\Android\Studio
• Flutter plugin version 39.0.3
• Dart plugin version 191.8423
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
[√] IntelliJ IDEA Ultimate Edition (version 2019.2)
• IntelliJ at C:\Users\Simon\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\192.6817.14
• Flutter plugin version 39.0.4
• Dart plugin version 192.6527
[√] VS Code, 64-bit edition (version 1.27.2)
• VS Code at C:\Program Files\Microsoft VS Code
• Flutter extension version 2.18.0
[√] Connected device (3 available)
• iPhone XR, 9 0, API 28 0 828x1792 • 192.168.188.109:5555 • android-x86 • Android 9 (API 28)
• Chrome • chrome • web-javascript • Google Chrome 77.0.3865.120
• Headless Server • headless-server • web-javascript • Flutter Tools
• No issues found!
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:5 (5 by maintainers)
Top Results From Across the Web
flutter - Cannot have function with generic parameter in ...
It's because _MyWidgetState doesn't know how to parameterize the type of its parent widget, so when you try to use widget.fn, the runtime...
Read more >StatefulWidget class - widgets library - Flutter - Dart API docs
A widget that has mutable state. State is information that (1) can be read synchronously when the widget is built and (2) might...
Read more >How to use same generic type in StatefulWidget and State ...
It gets called from the build() in the State class. That way the State class doesn't care about the generics. I would have...
Read more >Why Every Flutter Dev Should Care About BuildContext
Flutter allows us to build and rebuild widgets freely, and inexpensively. However, rebuilding a widget does not necessarily equate to the engine ...
Read more >StatelessWidget class - widgets library - Flutter - Dart API docs
A widget that does not require mutable state. A stateless widget is a widget that describes part of the user interface by building...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@pq yes, it has to propagate to the State.
Example:
@pq Since I was looking… here is the location of the bug.
https://github.com/dart-lang/sdk/blob/5300ce4a2dd0d39186d5eb9965bead92db906ab2/pkg/analysis_server/lib/src/services/correction/assist_internal.dart#L1557