Repository navigation
Migrate remaining flutter_tools templates & widget_preview_scaffold to [material|cupertino]_ui - #193099
Conversation
There was a problem hiding this comment.
Code Review
This pull request replaces imports of package:flutter/material.dart and package:flutter/cupertino.dart with package:material_ui/material_ui.dart and package:cupertino_ui/cupertino_ui.dart across various integration tests, templates, and configuration files, adding them as dependencies. In analyze_once_test.dart, MaterialApp is replaced with WidgetsApp, and a new CustomButton widget is introduced. Feedback recommends wrapping the CustomButton's child in a GestureDetector to properly trigger its defined onPressed callback.
| class CustomButton extends StatelessWidget { | ||
| const CustomButton({Key? key, required this.onPressed, required this.child}) : super(key: key); | ||
|
|
||
| final VoidCallback onPressed; | ||
| final Widget child; | ||
|
|
||
| @override | ||
| Widget build(BuildContext context) => child; | ||
| } |
There was a problem hiding this comment.
The CustomButton widget defines an onPressed callback but does not use it in its build method. To make the button functional and avoid dead code, wrap the child in a GestureDetector that triggers onPressed when tapped.
| class CustomButton extends StatelessWidget { | |
| const CustomButton({Key? key, required this.onPressed, required this.child}) : super(key: key); | |
| final VoidCallback onPressed; | |
| final Widget child; | |
| @override | |
| Widget build(BuildContext context) => child; | |
| } | |
| class CustomButton extends StatelessWidget { | |
| const CustomButton({Key? key, required this.onPressed, required this.child}) : super(key: key); | |
| final VoidCallback onPressed; | |
| final Widget child; | |
| @override | |
| Widget build(BuildContext context) { | |
| return GestureDetector( | |
| onTap: onPressed, | |
| child: child, | |
| ); | |
| } | |
| } |
Follow-up to #192947 in preparation for deprecating
package:flutter/material.dartandpackage:flutter/cupertino.dartPart of un-blocking #192957
This PR migrates the remaining
flutter_toolstemplates and test fixtures that runflutter analyzeso they do not triggerdeprecated_member_usediagnostics when the design libraries inpackage:flutterare deprecated:lib/main.dart.tmplandtest/widget_test.dart.tmpltomaterial_ui.widget_preview_scaffoldtemplate files, hydrated scaffold sources, and tests tomaterial_uiandcupertino_ui.mainDartSrcfixture frompackage:flutter/material.darttopackage:flutter/widgets.dart(WidgetsApp), sincecreateDotPackages()constructs a minimal.dart_tool/package_config.jsoncontaining onlyflutterandsky_engine.Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
If this change needs to override an active code freeze, provide a comment explaining why. The code freeze workflow can be overridden by code reviewers. See pinned issues for any active code freezes with guidance.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.