Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed all deprecated syntax #18

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .idea/codeStyles/codeStyleConfig.xml

This file was deleted.

26 changes: 0 additions & 26 deletions .idea/libraries/Dart_SDK.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/misc.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

38 changes: 19 additions & 19 deletions 02_built_in_data_types.dart
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
// ignore_for_file: unused_local_variable

void main(List<String> arguments) {
// Numbers: int
int score = 23;
var count = 23; // It is inferred as integer automatically by compiler
int hexValue = 0xEADEBAEE;

// Numbers: int
int score = 23;
var count = 23; // It is inferred as integer automatically by compiler
int hexValue = 0xEADEBAEE;
// Numbers: double
double percentage = 93.4;
var percent = 82.533;
double exponents = 1.42e5;

// Numbers: double
double percentage = 93.4;
var percent = 82.533;
double exponents = 1.42e5;
// Strings
String name = "Henry";
var company = "Google";

// Strings
String name = "Henry";
var company = "Google";
// Boolean
bool isValid = true;
var isAlive = false;

// Boolean
bool isValid = true;
var isAlive = false;
print(score);
print(exponents);

print(score);
print(exponents);

// NOTE: All data types in Dart are Objects.
// Therefore, their initial value is by default 'null'
// NOTE: All data types in Dart are Objects.
// Therefore, their initial value is by default 'null'
}
44 changes: 21 additions & 23 deletions 03_string_and_string_interpolation.dart
Original file line number Diff line number Diff line change
@@ -1,32 +1,30 @@
// ignore_for_file: unused_local_variable

void main() {
// Literals
var isCool = true;
int x = 2;
"John";
4.5;

// Literals
var isCool = true;
int x = 2;
"John";
4.5;
// Various ways to define String Literals in Dart
String s1 = 'Single';
String s2 = "Double";
String s3 = 'It\'s easy';
String s4 = "It's easy";

// Various ways to define String Literals in Dart
String s1 = 'Single';
String s2 = "Double";
String s3 = 'It\'s easy';
String s4 = "It's easy";
String s5 = 'This is going to be a very long String. '
'This is just a sample String demo in Dart Programming Language';

String s5 = 'This is going to be a very long String. '
'This is just a sample String demo in Dart Programming Language';
// String Interpolation : Use ["My name is $name"] instead of ["My name is " + name]
String name = "Kevin";

print("My name is $name");
print("The number of characters in String Kevin is ${name.length}");

// String Interpolation : Use ["My name is $name"] instead of ["My name is " + name]
String name = "Kevin";
int l = 20;
int b = 10;

print("My name is $name");
print("The number of characters in String Kevin is ${name.length}");


int l = 20;
int b = 10;

print("The sum of $l and $b is ${l + b}");
print("The area of rectangle with length $l and breadth $b is ${l * b}");
print("The sum of $l and $b is ${l + b}");
print("The area of rectangle with length $l and breadth $b is ${l * b}");
}
21 changes: 10 additions & 11 deletions 04_constants.dart
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
// ignore_for_file: unused_local_variable

void main() {
// final
final cityName = 'Mumbai';
// name = 'Peter'; // Throws an error

// final
final cityName = 'Mumbai';
// name = 'Peter'; // Throws an error
final String countryName = 'India';

final String countryName = 'India';

// const
const PI = 3.14;
const double gravity = 9.8;
// const
const PI = 3.14;
const double gravity = 9.8;
}

class Circle {

final color = 'Red';
static const PI = 3.14;
final color = 'Red';
static const PI = 3.14;
}
32 changes: 14 additions & 18 deletions 06_conditional_expressions.dart
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@

void main() {
// Conditional Expressions

// Conditional Expressions

// 1. condition ? exp1 : exp2
// If condition is true, evaluates expr1 (and returns its value);
// otherwise, evaluates and returns the value of expr2.

int a = 2;
int b = 3;

int smallNumber = a < b ? a : b;
print("$smallNumber is smaller");
// 1. condition ? exp1 : exp2
// If condition is true, evaluates expr1 (and returns its value);
// otherwise, evaluates and returns the value of expr2.

int a = 2;
int b = 3;

int smallNumber = a < b ? a : b;
print("$smallNumber is smaller");

// 2. exp1 ?? exp2
// If expr1 is non-null, returns its value; otherwise, evaluates and
// returns the value of expr2.
// 2. exp1 ?? exp2
// If expr1 is non-null, returns its value; otherwise, evaluates and
// returns the value of expr2.

String name = null;
var name = null;

String nameToPrint = name ?? "Guest User";
print(nameToPrint);
String nameToPrint = name ?? "Guest User";
print(nameToPrint);
}
38 changes: 18 additions & 20 deletions 07_switch_and_case.dart
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@

void main() {
// Switch Case Statements: Applicable for only 'int' and 'String'

// Switch Case Statements: Applicable for only 'int' and 'String'

String grade = 'A';
String grade = 'A';

switch (grade) {
switch (grade) {
case 'A':
print("Excellent grade of A");
break;

case 'A':
print("Excellent grade of A");
break;
case 'B':
print("Very Good !");
break;

case 'B':
print("Very Good !");
break;
case 'C':
print("Good enough. But work hard");
break;

case 'C':
print("Good enough. But work hard");
break;
case 'F':
print("You have failed");
break;

case 'F':
print("You have failed");
break;
default:
print("Invalid Grade");
}
default:
print("Invalid Grade");
}
}
30 changes: 14 additions & 16 deletions 08_for_loop.dart
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@

void main() {
// FOR Loop

// FOR Loop

// WAP to find the even numbers between 1 to 10

for (int i = 1; i <= 10; i++) {

if ( i % 2 == 0) {
print(i);
}
}
// WAP to find the even numbers between 1 to 10

for (int i = 1; i <= 10; i++) {
if (i % 2 == 0) {
print(i.toString() + ' par');
} else {
print(i.toString() + ' impar');
}
}

// for ..in loop
List planetList = ["Mercury", "Venus", "Earth", "Mars"];
// for ..in loop
List planetList = ["Mercury", "Venus", "Earth", "Mars"];

for (String planet in planetList) {
print(planet);
}
for (String planet in planetList) {
print(planet);
}
}
26 changes: 12 additions & 14 deletions 09_while_loop.dart
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@

void main() {

// WHILE Loop
// WAP to find the even numbers between 1 to 10

var i = 1;
while (i <= 10) {

if (i % 2 == 0) {
print(i);
}

i++;
}
// WHILE Loop
// WAP to find the even numbers between 1 to 10

var i = 0;
print('hello ws');
while (i <= 500) {
print(i);
if (i % 2 == 0) {
print(i);
}
i += 18;
}
}
27 changes: 13 additions & 14 deletions 11_break_keyword.dart
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@

void main() {
// BREAK keyword
// Using Labels
// Nested FOR Loop

// BREAK keyword
// Using Labels
// Nested FOR Loop

myOuterLoop: for (int i = 1; i <= 3; i++) {

innerLoop: for (int j = 1; j <= 3; j++) {
print("$i $j");
myOuterLoop:
for (int i = 1; i <= 3; i++) {
for (int j = 1; j <= 3; j++) {
print("$i $j");

if (i == 2 && j == 2) {
break myOuterLoop;
}
}
}
if (i == 2 && j == 2) {
print('breaking');
break myOuterLoop;
}
}
}
}
Loading