解决Flutter运行android提示Deprecated imperative apply of Flutter‘s Gradle plugins

Source

出现场景

ado@adodeMacBook-Air app_demo % flutter run --profile
Launching lib/main.dart on SM G977U in profile mode...
You are applying Flutter's app_plugin_loader Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future release. Migrate to applying Gradle plugins with the declarative plugins block: https://flutter.dev/to/flutter-gradle-plugin-apply

You are applying Flutter's main Gradle plugin imperatively using the apply script method, which is deprecated and will be removed in a future release. Migrate to applying Gradle plugins with the declarative plugins block: https://flutter.dev/to/flutter-gradle-plugin-apply

Running Gradle task 'assembleProfile'...                           17.7s

运行在安卓时,出现以上的警告.

解决方案

这是因为从Flutter 3.16开始,Android gradle插件使用plugin dsl语法 plugins{}块,

以下是移植方法

编辑