Singleton pattern is the design pattern to return only 1 instance of a class.
class Store {
static final Store _singleton = Store._internal();
List<Order> list = new List<Order>();
factory Store() {
return _singleton;
}
Store._internal();
addOrder(Order order){
list.Add(order);
}
}
To make a call to a function inside the singleton class:
Store().addOrder(order);