Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
0
Help us understand the problem. What is going on with this article?
@bikkurisaburou

Dartの配列(List)どうしの比較(忘備録)

DartのListはそのままだと比較できないのでその比較方法です。

  List listA = [1, 2, 3];
  List listB = [1, 2, 3];
  print(listA == listB); // false

方法1:foundation.dartを使う

import

import 'package:flutter/foundation.dart'; 

listEqualsを使う

  List listA = [1, 2, 3];
  List listB = [1, 2, 3];
  print(listEquals(listA, listB)); // true

方法2:collection.dartを使う

import

import 'package:collection/collection.dart'; 

※標準packageなのでpubspec.yamlなどへの追加は不要です

ListEquality().equalsを使う

  List listA = [1, 2, 3];
  List listB = [1, 2, 3];
  Function isEqual = const ListEquality().equals;
  print(isEqual(listA, listB)); // true

参照

0
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
0
Help us understand the problem. What is going on with this article?