Created
January 7, 2019 08:51
-
-
Save pseudo-su/1279097eb00a797209fe10741c735015 to your computer and use it in GitHub Desktop.
This file contains 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 SplashWidget extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return SplashStateProvider( // InheritedWidget | |
builder: (context, snapshot) { | |
final SplashState splashState = SplashState.of(context); | |
if (splashState.snapshot.isLoading) { | |
return Center( | |
// instead of the LoadingUI widget knowing about how to subscribe to items, we should be able to | |
// instead pass the already resolved items down the widget tree. | |
child: Loading(items: splashState.snapshot.items) | |
); | |
} | |
return Center(child: LoadingFinished()); | |
} | |
); | |
} | |
} | |
class Loading extends StatelessWidget { | |
@override | |
Widget build(items) { /* not exactly sure how you pass down values directly to widgets */ | |
return Flexible( | |
flex: 2, | |
child: Center( | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
crossAxisAlignment: CrossAxisAlignment.center, | |
children: items.map((item) { | |
var loadText = ''; | |
switch (item.status) { | |
case LoadingStatus.loading: | |
loadText = 'Loading...'; | |
break; | |
case LoadingStatus.loaded: | |
loadText = '✔️'; | |
break; | |
default: | |
loadText = ''; | |
} | |
return Text('${item.description}: $loadText'); | |
}).toList(), | |
); | |
}, | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment