Skip to content

Commit 4998823

Browse files
authored
Merge pull request #248 from akashgk/migrate
Migrate to Null Safety, Update Actions, Fix #176
2 parents 67ff979 + 375057e commit 4998823

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+229
-455
lines changed

.github/workflows/dart_test_analyze_format.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,13 @@ on: [push, pull_request]
33
jobs:
44
dart_test_analyze_format:
55
runs-on: ubuntu-latest
6-
container: google/dart
6+
container:
7+
image: google/dart
78
steps:
89
- uses: actions/checkout@v2
9-
- run: (echo 'deb http://deb.debian.org/debian buster main contrib non-free') > /etc/apt/sources.list.d/buster.list
10-
- run: apt-get update
11-
- run: apt-get install --no-install-recommends -y -q lcov
10+
# - run: (echo 'deb http://deb.debian.org/debian buster main contrib non-free') > /etc/apt/sources.list.d/buster.list
1211
- run: dart pub get
1312
- run: dart format --set-exit-if-changed .
1413
- run: dart test --coverage .
1514
- run: dart pub run coverage:format_coverage -i . -l > coverage.lcov
16-
- run: lcov -l coverage.lcov
1715
- run: dart analyze

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ doc/api/
1919
*.js_
2020
*.js.deps
2121
*.js.map
22+
*.json

DIRECTORY.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@
4343
* [Cycle In Linked List](https://github.com/TheAlgorithms/Dart/blob/master/data_structures/linked_list/cycle_in_linked_list.dart)
4444
* [Linked List](https://github.com/TheAlgorithms/Dart/blob/master/data_structures/linked_list/linked_list.dart)
4545
* [Merge Sorted List](https://github.com/TheAlgorithms/Dart/blob/master/data_structures/linked_list/merge_sorted_list.dart)
46-
* Quad Tree
47-
* [Quad Tree](https://github.com/TheAlgorithms/Dart/blob/master/data_structures/quad_tree/quad_tree.dart)
4846
* Queue
4947
* [Circular Queue](https://github.com/TheAlgorithms/Dart/blob/master/data_structures/Queue/Circular_Queue.dart)
5048
* [List Queue](https://github.com/TheAlgorithms/Dart/blob/master/data_structures/Queue/List_Queue.dart)

array/car_pool.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Solution Explanation: https://leetcode.com/problems/car-pooling/solutions/3252690/dart-time-o-n-o-1-space-solution/
33

44
import 'dart:math';
5-
import 'package:test/test.dart';
5+
import "package:test/test.dart";
66

77
bool carPooling(List<List<int>> trips, int capacity) {
88
List<int> passengerTimelineCount = List.filled(1001, 0);

conversions/Decimal_To_Any.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,10 @@ String decimalToAny(int value, int base) {
4848
while (value > 0) {
4949
int remainder = value % base;
5050
value = value ~/ base;
51-
output =
52-
(remainder < 10 ? remainder.toString() : ALPHABET_VALUES[remainder]) +
53-
output;
51+
output = (remainder < 10
52+
? remainder.toString()
53+
: ALPHABET_VALUES[remainder] ?? '0') +
54+
output;
5455
}
5556

5657
return negative ? '-' + output : output;

conversions/Decimal_to_Hexadecimal.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ String decimal_to_hexadecimal(int decimal_val) {
2727
int remainder = decimal_val % 16;
2828
decimal_val = decimal_val ~/ 16;
2929
if (hex_table.containsKey(remainder.toString())) {
30-
hex_val = hex_table[remainder.toString()];
30+
hex_val = hex_table[remainder.toString()] ?? '';
3131
} else {
3232
hex_val = remainder.toString();
3333
}

conversions/Integer_To_Roman.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ List<String> RomanNumbers = [
4141

4242
List<String> integer_to_roman(int num) {
4343
if (num < 0) {
44-
return null;
44+
return [];
4545
}
4646

4747
List<String> result = [];

conversions/binary_to_decimal.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import 'package:test/test.dart';
44

55
int binaryToDecimal(String binaryString) {
66
binaryString = binaryString.trim();
7-
if (binaryString == null || binaryString == "") {
7+
if (binaryString == "") {
88
throw FormatException("An empty value was passed to the function");
99
}
1010
bool isNegative = binaryString[0] == "-";
@@ -14,8 +14,8 @@ int binaryToDecimal(String binaryString) {
1414
if ("01".contains(binaryString[i]) == false) {
1515
throw FormatException("Non-binary value was passed to the function");
1616
} else {
17-
decimalValue +=
18-
pow(2, binaryString.length - i - 1) * int.parse((binaryString[i]));
17+
decimalValue += (pow(2, binaryString.length - i - 1).toInt() *
18+
(int.tryParse(binaryString[i]) ?? 0));
1919
}
2020
}
2121
return isNegative ? -1 * decimalValue : decimalValue;

conversions/binary_to_hexadecimal.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Map<String, String> hexTable = {
2424
String binaryToHexadecimal(String binaryString) {
2525
// checking for unexpected values
2626
binaryString = binaryString.trim();
27-
if (binaryString == null || binaryString == "") {
27+
if (binaryString.isEmpty) {
2828
throw new FormatException("An empty value was passed to the function");
2929
}
3030
try {
@@ -47,7 +47,7 @@ String binaryToHexadecimal(String binaryString) {
4747
int i = 0;
4848
while (i != binaryString.length) {
4949
String bin_curr = binaryString.substring(i, i + 4);
50-
hexValue += hexTable[bin_curr];
50+
hexValue += hexTable[bin_curr] ?? '';
5151
i += 4;
5252
}
5353

conversions/binary_to_octal.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ void main() {
2121

2222
String binaryToOctal(String binaryString) {
2323
binaryString = binaryString.trim();
24-
if (binaryString == null || binaryString == "") {
24+
if (binaryString.isEmpty) {
2525
throw new FormatException("An empty value was passed to the function");
2626
}
2727
bool isNegative = binaryString[0] == "-";

0 commit comments

Comments
 (0)