Skip to content

Commit 764bb64

Browse files
committed
added dart language,category,snippets
Added Dart Snippets added icon categories such as: array-manipulation, file-manipulation, string-manipulation, date-and-time
1 parent 06e4987 commit 764bb64

29 files changed

+352
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
title: Filter a List
3+
description: Filters a list to include only even numbers.
4+
author: Vrindtime
5+
tags: dart,collections,list,utility
6+
---
7+
8+
```dart
9+
final numbers = [1, 2, 3, 4, 5, 6];
10+
final evens = numbers.where((n) => n.isEven).toList();
11+
print(evens); // Prints [2, 4, 6]
12+
```
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
title: Find Index of an Element
3+
description: Finds and prints the index of a specific element in an array.
4+
author: Vrindtime
5+
tags: dart,array-manipulation,utility
6+
---
7+
8+
```dart
9+
final numbers = [10, 20, 30, 40, 50];
10+
final index = numbers.indexOf(30);
11+
print(index); // Prints 2
12+
```
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
title: Find Maximum in an Array
3+
description: Finds and prints the maximum value in an array.
4+
author: Vrindtime
5+
tags: dart,array-manipulation,utility
6+
---
7+
8+
```dart
9+
final numbers = [3, 7, 2, 9, 4];
10+
final maxNumber = numbers.reduce((a, b) => a > b ? a : b);
11+
print(maxNumber); // Prints 9
12+
```
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
title: Remove Duplicates from an Array
3+
description: Removes duplicate elements from an array and prints the result.
4+
author: Vrindtime
5+
tags: dart,array-manipulation,utility
6+
---
7+
8+
```dart
9+
final numbers = [1, 2, 2, 3, 4, 4, 5];
10+
final uniqueNumbers = numbers.toSet().toList();
11+
print(uniqueNumbers); // Prints [1, 2, 3, 4, 5]
12+
```
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
title: Remove Specific Element from an Array
3+
description: Removes a specific element from an array and prints the result.
4+
author: Vrindtime
5+
tags: dart,array-manipulation,utility
6+
---
7+
8+
```dart
9+
final numbers = [1, 2, 3, 4, 5];
10+
numbers.remove(3);
11+
print(numbers); // Prints [1, 2, 4, 5]
12+
```
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
title: Reverse an Array
3+
description: Reverses an array and prints the result.
4+
author: Vrindtime
5+
tags: dart,array-manipulation,utility
6+
---
7+
8+
```dart
9+
final numbers = [1, 2, 3, 4, 5];
10+
final reversed = numbers.reversed.toList();
11+
print(reversed); // Prints [5, 4, 3, 2, 1]
12+
```
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
title: Shuffle an Array
3+
description: Randomly shuffles the elements of an array and prints the result.
4+
author: Vrindtime
5+
tags: dart,array-manipulation,utility
6+
---
7+
8+
```dart
9+
final numbers = [1, 2, 3, 4, 5];
10+
numbers.shuffle(Random());
11+
print(numbers); // Prints the array in random order
12+
```
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
title: Sort an Array
3+
description: Sorts an array in ascending order and prints it.
4+
author: Vrindtime
5+
tags: dart,array-manipulation,utility
6+
---
7+
8+
```dart
9+
final numbers = [5, 1, 8, 3, 2];
10+
numbers.sort();
11+
print(numbers); // Prints [1, 2, 3, 5, 8]
12+
```

snippets/dart/basics/hello-world.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
title: Hello, World!
3+
description: Prints Hello, World! to the terminal.
4+
author: Vrindtime
5+
tags: dart,printing,hello-world,utility
6+
---
7+
8+
```dart
9+
print("Hello, World!"); // Prints Hello, World! to the console
10+
```
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
title: Add Duration to DateTime
3+
description: Adds a specified duration to a DateTime object and prints the result.
4+
author: Vrindtime
5+
tags: dart,date-time,utility
6+
---
7+
8+
```dart
9+
final now = DateTime.now();
10+
final future = now.add(Duration(days: 7,hours: 10,minutes: 5,seconds: 2,microseconds: 100,milliseconds: 50));
11+
print(future); // Prints the date and time 7 days, 10 hours, 5 minutes, 2 seconds, 100 microseconds and 50 miliseconds from now
12+
```

0 commit comments

Comments
 (0)