Flutterの「Unnecessary ‘new’ keyword. (Documentation) Try removing the ‘new’ keyword.」の意味と対策について紹介します。
Unnecessary ‘new’ keyword. (Documentation) Try removing the ‘new’ keyword.
margin: new EdgeInsets.fromLTRB(1, 0, 1, 0));
Flutterの上記部分に対して、以下のような修正案のメッセージが提示されていました。
Unnecessary 'new' keyword. (Documentation) Try removing the 'new' keyword.
Use 'const' with the constructor to improve performance. (Documentation) Try adding the 'const' keyword to the constructor invocation.
「newは不要なので、削除してみてください。パフォーマンスを向上させるには、コンストラクターで ‘const’ を使用します。コンストラクターの呼び出しに「const」キーワードを追加してみてください。」ということなので、以下のようにnewを削除してconstに修正するとメッセージが消えました。
margin: const EdgeInsets.fromLTRB(1, 0, 1, 0));
【Flutter入門】iOS、Android、Windowsアプリ開発
FlutterによるiOS、Android、Windowsアプリ開発について入門者向けに紹介します。
コメント