Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Server Side Programming Articles - Page 1044 of 2650
9K+ Views
The ternary operator is a shorthand version of an if-else condition. There are two types of ternary operator syntax in Dart, one with a null safety check and the other is the same old one we encounter normally.Syntax 1condition ? expressionOne : expressionTwo;The above syntax implies that if a certain condition evaluates to true then we evaluate the expressionOne first and then the expressionTwo.ExampleLet's explore a Dart example where we make use of the above syntax of the ternary operator.Consider the example shown below − Live Demovoid main(){ var ans = 10; ans == 10 ? print("Answer is 10") ... Read More
221 Views
Switch statements help us in cases where we want to run specific code based on certain conditions. It's true that if-else conditions also help us in the same section of code, but the switch statements reduce the complexity of the program as we will end up with less code in case of a switch if the condition checks are dense.Syntaxswitch(case){ case x: // do something; break; case y: // do something; break; default: // do something; }ExampleConsider the example shown below − Live ... Read More
702 Views
Super keyword in dart is used to refer to the parent's class object's methods or variables. In simple terms, it is used to refer to the superclass properties and methods.The most important use of the super keyword is to remove the ambiguity between superclass and subclass that have methods and variables with the same name.The super keyword is able to invoke the parent's objects method and fields, as when we create an instance of the subclass in Dart, an instance of the parent class is also created implicitly.Syntaxsuper.varName or super.methodNameAs we can access both the variables and methods of the parent's ... Read More
705 Views
The subclass can inherit the superclass methods and variables, but it cannot inherit the superclass constructor. The superclass constructor can only be invoked with the use of the super() constructor.The super() constructor allows a subclass constructor to explicitly call the no arguments and parametrized constructor of superclass.SyntaxSubclassconstructor():super(){ }Though, it is not even necessary to use the super() keyword as the compiler automatically or implicitly does the same for us.When an object of a new class is created by making use of the new keyword, it invokes the subclass constructor which implicitly invokes the parent class's default constructor.Let's make use of an example where ... Read More
273 Views
Strings in Dart have certain properties attached to them. These properties come in handy in different use cases.The most common used string properties are −hashCodeisEmptyisNotEmptylengthrunesIn this article, we will explore all the above mentioned properties of a string.hashCodeThe hashCode property of a string is used to print the hashCode number of the specific string on which it is called.ExampleConsider the example shown below − Live Demovoid main(){ String name = "Tutorials Point"; print(name.hashCode); }Output147510269isEmptyThe isEmpty property of a string returns true when the string is an empty string.ExampleConsider the example shown below − Live Demovoid main(){ String name = "Tutorials Point"; ... Read More
781 Views
String class in Dart contains different methods that we use to make working with strings easier and more expressive.There are many methods present in the String class, some of the common ones are −contains(Pattern)trim()toLowerCase()toUpperCase()split(Pattern)compareTo(another string)We will explore each of the above string methods in this article.contains() methodThe contains() method is used to find a pattern present in the string or not. If the pattern that we are searching is present in the string, then the contains() method returns true, else it returns false.ExampleConsider the example shown below − Live Demovoid main(){ String name = " Tutorials Point "; print(name.contains("Point")); ... Read More
2K+ Views
There are times when we want to make use of variables inside the statement that is made up of string values.We know that we can add two strings together in Dart with the help of the + symbol operator. But to make use of a variable in between the strings that we are concatenating, we need to add one more + symbol and then type the name of the variable, which works okay when it comes to small statements.ExampleConsider the example shown below − Live Demovoid main(){ String name = "Tutorials"; var collegeName = "DTU"; print("Name is " ... Read More
355 Views
A String in dart is a sequence or series of characters. The characters can be - special characters, numbers or letters. In Dart, we can represent strings with both the single quotes and double quotes.Example'a string value' or "another string value"Both the examples are valid examples of a string in Dart.In Dart, we can declare strings with the help of the String keyword and also we can use the var keyword as well.ExampleConsider the example shown below − Live Demovoid main(){ String name = "Tuts"; var herName = "Shreya"; print(name); print(herName); }In the above example, we have ... Read More
498 Views
A set is a collection of objects in which each object can occur exactly once. It implies that all the objects in the element type, are either in the set or not in the set.A set is an important data structure and is very helpful in cases where we need exactly one occurrence of each object.There are multiple ways in dart with which we can create a Set, but the default way of making use of the Set() constructor is the most common one.ExampleConsider the example shown below − Live Demovoid main() { var fruits = new Set(); print(fruits); ... Read More
446 Views
We know that strings in Dart are a sequence of Unicode UTF-16 characters. Dart Runes are actually UTF-32 Unicode code points.They are UTF-32 string which is used to print special symbols.For example, the theta symbol in dart is displayed when we assign the Unicode equivalent value of '\u0398' to a variable.ExampleConsider the example shown below − Live Demovoid main(){ var heartSymbol = '\u0398'; print(heartSymbol); }OutputΘThere are different methods/properties that we can apply on dart Runes to extract the string core units. These mainly are −string.codeUnitAt()string.codeUnitsstring.runesstring.codeUnitAt()The string.codeUnitAt() method is used to access the character's code unit that is present inside ... Read More