Instance method in Dart with examples

Instance methods in Dart : In simple words, instance methods are methods defined in a class those are available with class objects. Instance methods can access to instance variables and this. For example, let’s consider the below program : class Student { final String name; final num age; const Student(this.name, Read more…

Dart instance variable examples

Dart instance variable examples

Introduction : Instance variables are variables declared inside a class. Every object of that class gets a new copy of instance variables. In this post, we will learn how instance variables work and different ways to initialize them.   Example of instance variable : Let’s consider the below example : Read more…

Different Dart class constructors

Introduction : You must be familiar with the term class if you have worked on any object-oriented programming language. Objects are an instance of classes. Class is a blueprint and objects are created using that blueprint. A constructor is a method defined in a class that is called while initializing Read more…

Dart string replaceAll example

Dart String replaceAll method

Introduction : replaceAll is a dart string method that replaces part of a string defined by a pattern with a given value. It creates the new string and returns it.   Syntax : replaceAll is defined as below : String replaceAll(Pattern from, String replace) Here, from : Pattern to replace Read more…

dart throw exception

How to throw an exception in Dart

How to throw an exception in Dart : We can throw an exception manually in Dart. Dart has a couple of predefined Exceptions and these are thrown automatically on any unexpected result. You can raise predefined exceptions, custom exceptions or arbitrary objects. In this post, I will quickly show you Read more…