This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | myReduxStore.onChange | |
| .map((s) => MyViewModel(s)) | |
| .distinct() | |
| .listen( /* update UI */ ); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | StreamBuilder<String>( | |
| stream: NumberCreator().stream.map((i) => 'String $i'), | |
| builder: (context, snapshot) { | |
| if (snapshot.connectionState == ConnectionState.waiting) { | |
| return Text('No data yet.'); | |
| } else if (snapshot.connectionState == ConnectionState.done) { | |
| return Text('Done!'); | |
| } | |
| } | |
| ) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | StreamBuilder<String>( | |
| stream: NumberCreator().stream.map((i) => 'String $i'), | |
| builder: (context, snapshot) { | |
| /* Build widgets! */ | |
| } | |
| ) | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | class NumberCreator { | |
| NumberCreator() { | |
| Timer.periodic(Duration(seconds: 1), (t) { | |
| _controller.sink.add(_count); | |
| _count++; | |
| }); | |
| } | |
| var _count = 1; | |
| final _controller = StreamController<int>(); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | final myStream = NumberCreator().stream.asBroadcastStream(); | |
| final subscription = myStream.listen( | |
| (data) => print('Data: $data'), | |
| ); | |
| final subscription2 = myStream.listen( | |
| (data) => print('Data again: $data'), | |
| ); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | final myStream = NumberCreator().stream; | |
| final subscription = myStream.listen( | |
| (data) => print('Data: $data'), | |
| ); | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | // Add a contravariant variance modifier | |
| class Writer<in T> { | |
| void write(T x) => print(x); | |
| } | |
| main() { | |
| // Error! Cannot assign Writer<int> to Writer<Object> because the type | |
| // parameter is contravariantly declared. | |
| Writer<Object> objectWriter = new Writer<int>(); | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | void main() { | |
| var iterable = ['Salad', 'Popcorn', 'Toast']; | |
| for (var element in iterable) { | |
| print(element); | |
| } | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | void main() { | |
| Iterable iterable = ['Salad', 'Popcorn', 'Toast']; | |
| print('The first element is ${iterable.first}'); | |
| print('The last element is ${iterable.last}'); | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | bool predicate(String element) { | |
| return element.length > 5; | |
| } | |
| main() { | |
| var items = ['Salad', 'Popcorn', 'Toast', 'Lasagne']; | |
| // You can find with a simple expression: | |
| var element1 = items.firstWhere((element) => element.length > 5); | |
| print(element1); |