Home Python C Language C ++ HTML 5 CSS Javascript Java Kotlin SQL DJango Bootstrap React.js R C# PHP ASP.Net Numpy Dart Pandas Digital Marketing

Learn Dart Expression

In Dart, an expression is a combination of variables, operators, and method invocations that produces a value. Expressions can range from simple arithmetic calculations to complex logical evaluations.

1. Arithmetic Expressions:

var sum = 10 + 5; // Addition
var difference = 10 - 5; // Subtraction
var product = 10 * 5; // Multiplication
var quotient = 10 / 5; // Division


2. String Concatenation:

var greeting = 'Hello' + ' ' + 'World'; // Concatenation


3. Comparison Expressions:

var isEqual = (10 == 5); // Equality comparison
var isGreater = (10 > 5); // Greater than comparison


4. Logicial Expressions:

var isTrue = true;
var isFalse = false;
var result = (isTrue && isFalse); // Logical AND


4. Conditional Expressions::

var age = 20;
var isAdult = (age >= 18) ? true : false; // Ternary operator


5. Function Calls:

int add(int a, int b) {
return a + b;
}
var result = add(10, 5); // Function invocation


5. Property Access Expressions::

class Person {
String name;
int age;
} var person = Person();
person.name = 'Alice'; // Property access


5. Cascade Notation::

var person = Person()
..name = 'Bob'
..age = 30; // Cascade notation


Expressions in Dart can be as simple as a single variable or as complex as a combination of multiple operations. They form the building blocks of Dart programs, allowing you to manipulate data and control program flow effectively.






Advertisement





Q3 Schools : India


Online Complier

HTML 5

Python

java

C++

C

JavaScript

Website Development

HTML

CSS

JavaScript

Python

SQL

Campus Learning

C

C#

java