こんにちは、フラメルです。
今回はList
から指定した要素を削除する方法を紹介します。
目次
Listから指定した要素を削除する方法
List
から指定した同じ要素を削除するにはremove
メソッドに削除したい要素の値を渡します。
配列に指定した要素が含まれている場合は配列から要素を削除し「true」を返し、含まれていない場合は「false」を返します。
void main() {
var fruits = ['apple', 'banana', 'grape', 'lemon'];
print(fruits.remove('banana')); //true
print(fruits.remove('orange')); //false
print(fruits); //[apple, grape, lemon]
}
以上です。
合わせて読みたい
あわせて読みたい


【Flutter】Durationの使い方|時間・期間の指定
こんにちは、フラメルです。 今回はアニメーション時間や期間を指定する際に使用されるDurationの使い方を紹介します。 Durationの基本的な使い方 Durationでは下記コー…
あわせて読みたい


【Flutter】AnimatedOpacityの使い方|透明度をアニメーションで変更
こんにちは、フラメルです。 今回は任意のウィジェットの透明度をアニメーションで徐々に変更できるAnimatedOpacityの使い方を紹介します。 アニメーションで透明度を徐…