Dart DocumentationenumeratorsThunk<A>

Thunk<A> class

class Thunk<A> {
 A _cached;
 Function gen;
 Thunk(A gen()) : this.gen = gen;
 A get value {
   if (_cached == null) {
     _cached = gen();
   }
   return _cached;
 }
}

Constructors

new Thunk(A gen()) #

Creates a new Object instance.

Object instances have no meaningful state, and are only useful through their identity. An Object instance is equal to itself only.

docs inherited from Object
Thunk(A gen()) : this.gen = gen;

Properties

Function gen #

Function gen

final A value #

A get value {
 if (_cached == null) {
   _cached = gen();
 }
 return _cached;
}