Bibek Kakati
Bibek's Blog

Bibek's Blog

Implementing Singleton Pattern In Dart - Flutter

Bibek Kakati
ยทApr 19, 2021ยท

1 min read

Implementing Singleton Pattern In Dart - Flutter

Subscribe to my newsletter and never miss my upcoming articles

Play this article

What is a singleton pattern?

Singleton pattern is a design pattern that allows us to use a single instance of a class everywhere.


class ClassName {
    static ClassName _className;

    factory ClassName() {
        if (_className == null) {
            _className = ClassName._createInstance();
       return _className;

Factory constructors return an instance of the class, but it doesn't necessarily create a new instance.

Thank you for reading ๐Ÿ™

If you enjoyed this article or found it helpful, give it a thumbs-up ๐Ÿ‘

Feel free to connect ๐Ÿ‘‹

Twitter | Instagram | LinkedIn

Share this