Last active
March 24, 2019 14:34
-
-
Save rapPayne/ce60a3088266188cf5538615182e8342 to your computer and use it in GitHub Desktop.
React Native vs Flutter - Flutter's build method
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
| @override | |
| Widget build(BuildContext context) { | |
| return StoreProvider<AppState>( | |
| store: this.store, | |
| child: StoreConnector<AppState, AppState>(converter: (store) { | |
| return store.state; | |
| }, | |
| builder: (context, callback) { | |
| if (store.state.showFilmDetails) // <-- 9 | |
| return showFilmDetails(this.store.state.selectedFilm); // <-- 9 | |
| return SingleChildScrollView( // <-- 11 | |
| child: Column( // <-- 12 | |
| children: <Widget>[ | |
| Row( | |
| children: <Widget>[ | |
| Image.asset("images/daam.png", height: 75, fit: BoxFit.cover), // <-- 13 | |
| Text("Dinner and a Movie",style: | |
| TextStyle( fontWeight: FontWeight.bold, fontSize: 30)), // <-- 14 | |
| ], | |
| mainAxisAlignment: MainAxisAlignment.start, | |
| crossAxisAlignment: CrossAxisAlignment.start, | |
| ), | |
| Text("Tap a movie below to see its details. Then pick a date // <-- 15 | |
| to see showtimes."), | |
| DatePicker(store.state.selectedDate, this.store), // <-- 16 | |
| store.state.showings == null || store.state.selectedFilm == null // <-- 17 | |
| ? Text("") // <-- 17 | |
| : ShowingTimes( // <-- 17 | |
| showings: store.state.showings, | |
| selectedDate: store.state.selectedDate, | |
| film: this.store.state.selectedFilm), | |
| Column( | |
| children: this.store.state.films.map<Widget>( // <-- 18 | |
| (film) => new FilmBrief(film: film, store: this.store) | |
| ).toList()), | |
| ])); | |
| } | |
| Widget showFilmDetails(film) { // <-- 19 | |
| return SingleChildScrollView(child: Column( | |
| children: <Widget>[ | |
| FilmDetails(film: this.store.state.selectedFilm, | |
| selectedDate: this.store.state.selectedDate, | |
| showings: this.store.state.showings), | |
| RaisedButton( | |
| child:Text("Done"), | |
| onPressed: () => store.dispatch({'type': Actions.HIDE_FILM_DETAILS }) | |
| ), | |
| ] | |
| )); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment