Skip to content

Commit

Permalink
Added lazy list example.
Browse files Browse the repository at this point in the history
  • Loading branch information
simphotonics committed Aug 11, 2023
1 parent c34087f commit b23d62d
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions example/bin/lazy_list_example.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import 'package:lazy_memo/lazy_memo.dart';

void main(List<String> args) {
final origin = <String>['zero', 'one', 'two'];

var lazyList = LazyList<String>(() => [...origin, 'three']);

// The object
print(lazyList);
// The cached list view
print(lazyList());

// Returns the same object till it is re-initialized.
print(lazyList() == lazyList());
print(lazyList() == lazyList(updateCache: true));

origin.add('four');

print(lazyList(updateCache: true));
}

0 comments on commit b23d62d

Please sign in to comment.