Print instance of object flutter

In Flutter, everything is considered as an object. When we say “print instance of object flutter”, it means we want to print the instance or the specific object that is associated with the Flutter framework. Here’s an example of how you can print the instance of the Flutter object in Dart code:


void main() {
  var flutterInstance = Flutter();
  print(flutterInstance);
}

class Flutter {
  String version = "2.2.3"; 
  String framework = "UI Toolkit";

  @override
  String toString() {
    return "Flutter version $version, $framework for building beautiful user interfaces.";
  }
}

  

In the above example, we have created a class called “Flutter” which represents the Flutter framework. It has two properties, “version” and “framework”. The class also overrides the toString() method to provide a custom string representation of the object.

In the main function, we create an instance of the Flutter class called “flutterInstance” and then print it using the print() function. The output will be:


Flutter version 2.2.3, UI Toolkit for building beautiful user interfaces.

  

This output confirms that we have successfully printed the instance of the Flutter object.

Leave a comment