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
    
  
  
    
  | typedef CompleterBlock<T> = void Function(Completer<T> completer); | |
| Future<T> completer<T>(final CompleterBlock<T> block) { | |
| assert(block != null); | |
| final completer = Completer<T>(); | |
| block(completer); | |
| return completer.future; | |
| } | 
  
    
      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
    
  
  
    
  | import 'dart:collection'; | |
| import 'package:mockito/mockito.dart'; | |
| typedef ComputedAnswer<T> = T Function(); | |
| class AnswerBuilder<T> implements _AnswerBuilderNode { | |
| @override | |
| final AnswerBuilder<T> _parent; | |
| @override | 
  
    
      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
    
  
  
    
  | Future<FirebaseUser> login() async { | |
| final googleUser = await _googleSignIn.signIn(); | |
| final googleAuth = await googleUser.authentication; | |
| final authCredential = GoogleAuthProvider.getCredential( | |
| idToken: googleAuth.idToken, | |
| accessToken: googleAuth.accessToken | |
| ); | |
| return await _firebaseAuth.signInWithCredential(authCredential); | |
| } | 
  
    
      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 Transient<T> { | |
| T _value; | |
| Transient(T value) { | |
| this._value = value; | |
| } | |
| void use(Function(T value) block) { | |
| assert(block != null); | |
| if (_value != null) { | 
  
    
      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
    
  
  
    
  | import 'package:flutter/widgets.dart'; | |
| import 'package:flutter_mobx/flutter_mobx.dart'; | |
| import 'package:provider/provider.dart'; | |
| typedef ConsumerObserverBuilder<T> = Widget Function(BuildContext context, T value); | |
| class ConsumerObserver<T> extends StatelessWidget { | |
| final ConsumerObserverBuilder<T> builder; | |
| final Widget prebuiltChild; | 
  
    
      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
    
  
  
    
  | import 'package:mobx/mobx.dart'; | |
| part 'counter_store.g.dart'; | |
| class CounterStore = _CounterStore with _$CounterStore; | |
| abstract class _CounterStore with Store { | |
| @observable | |
| int counter1 = 0; | 
  
    
      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
    
  
  
    
  | inline fun <V : View, I> V.trackInstance( | |
| newInstance: I?, | |
| @IdRes instanceResId: Int, | |
| onDetached: V.(I) -> Unit = {}, | |
| onAttached: V.(I) -> Unit = {} | |
| ) { | |
| ListenerUtil.trackListener(this, newInstance, instanceResId).let { oldInstance -> | |
| if (oldInstance !== newInstance) { // referential comparison | |
| oldInstance?.let { onDetached(oldInstance) } | |
| newInstance?.let { onAttached(newInstance) } | 
  
    
      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 MyViewModel : ViewModel() { | |
| @get:MainThread | |
| val users: LiveData<List<String>> by unsafeLazy { | |
| MutableLiveData<List<String>>().apply { loadUsersInto(this) } | |
| } | |
| private fun loadUsersInto(liveData: MutableLiveData<List<String>>) { | |
| // do async operation to fetch users and update | |
| } | 
  
    
      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
    
  
  
    
  | import android.arch.lifecycle.ViewModel | |
| import android.arch.lifecycle.ViewModelProvider | |
| import android.arch.lifecycle.ViewModelProviders | |
| import android.support.v4.app.Fragment | |
| import android.support.v4.app.FragmentActivity | |
| /** | |
| * Implementation of [ViewModelProvider.Factory] that takes care of the slightly awkward generic method [ViewModelProvider.Factory.create] | |
| * | |
| * It removes the need for the client to manually handle the given ViewModel [Class] in an if else clause or switch statement, or perform type casting when returning. | 
  
    
      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
    
  
  
    
  | fun <T> BaseObservable.bindable(initialValue: T, propertyId: Int): BindableProperty<T> { | |
| return BindableProperty<T>(initialValue, this) | |
| } | |
| class BindableProperty<T>(initialValue: T, | |
| private val observable: BaseObservable) : ObservableProperty<T>(initialValue) { | |
| private var propertyId: Int = 0 | |
| override fun beforeChange(property: KProperty<*>, oldValue: T, newValue: T): Boolean { |