Skip to content

Instantly share code, notes, and snippets.

@rapPayne
Last active March 24, 2019 14:34
Show Gist options
  • Select an option

  • Save rapPayne/ce60a3088266188cf5538615182e8342 to your computer and use it in GitHub Desktop.

Select an option

Save rapPayne/ce60a3088266188cf5538615182e8342 to your computer and use it in GitHub Desktop.
React Native vs Flutter - Flutter's build method
@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