Trusted answers to developer questions

Harris Amjad

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

The ** set.isNotEmpty function** in Dart is used to check if a set is empty or not.

`set.isNotEmpty`

returns `true`

if a set is not empty; otherwise, it returns `false`

.The image below shows the visual representation of the `set.isNotEmpty`

function.

In Dart, a

is a particular instance of a list in which all of the inputs are unique.`set`

`dart:core`

is required in order to use this function.

```
set_name.isNotEmpty
```

`set_name`

is the name of the set.

The `set.isNotEmpty`

function does not require any parameters.

If the set is not empty, the `set.isNotEmpty`

function returns `true`

; otherwise, it returns `false`

.

If there are duplicates, then the set will only keep the first instance. For instance,

`{'Tom','Alsvin','Eddie','Tom'}`

will result in`{'Tom','Alsvin','Eddie'}`

.

The code below shows how to use the `set.isNotEmpty`

function in Dart.

import 'dart:convert';import 'dart:core';void main() {Set<String> set_1 = {'Tom','Alsvin','Eddie'};//set containing unique valueprint("set_1 is not empty: ${set_1.isNotEmpty}");//empty setSet<String> set_2 = {};print("set_2 is not empty: ${set_2.isNotEmpty}");//set containing non-unique valueSet<String> set_3 = {'Tom','Alsvin','Eddie','Tom'};print("set_3 is not empty: ${set_3.isNotEmpty}");}

RELATED TAGS

dart

communitycreator

CONTRIBUTOR

Harris Amjad

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring

Related Courses