bare implementation of comuncation with the api
This commit is contained in:
@@ -20,26 +20,40 @@ class Greeter extends StatefulWidget {
|
||||
class _GreeterState extends State<Greeter> {
|
||||
Widget greeterBuild (BuildContext context, AsyncSnapshot<Trip> snapshot) {
|
||||
ThemeData theme = Theme.of(context);
|
||||
String cityName = "";
|
||||
Widget topGreeter;
|
||||
if (snapshot.hasData) {
|
||||
cityName = snapshot.data?.cityName ?? '...';
|
||||
topGreeter = Padding(
|
||||
padding: const EdgeInsets.only(top: 20, bottom: 20),
|
||||
child: Text(
|
||||
'Welcome to ${snapshot.data?.cityName}!',
|
||||
style: TextStyle(color: theme.primaryColor, fontWeight: FontWeight.bold, fontSize: 24),
|
||||
)
|
||||
);
|
||||
} else if (snapshot.hasError) {
|
||||
cityName = "error";
|
||||
} else { // still awaiting the cityname
|
||||
cityName = "...";
|
||||
topGreeter = const Padding(
|
||||
padding: EdgeInsets.only(top: 20, bottom: 20),
|
||||
child: Text('Error while fetching trip')
|
||||
);
|
||||
} else {
|
||||
// still awaiting the cityname
|
||||
// Show a linear loader at the bottom and an info message above
|
||||
topGreeter = Column(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 20, bottom: 20),
|
||||
child: const Text('Generating your trip...', style: TextStyle(fontSize: 20),)
|
||||
),
|
||||
const LinearProgressIndicator()
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
Widget topGreeter = Text(
|
||||
'Welcome to $cityName!',
|
||||
style: TextStyle(color: theme.primaryColor, fontWeight: FontWeight.bold, fontSize: 24),
|
||||
);
|
||||
|
||||
|
||||
if (widget.standalone) {
|
||||
return Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(top: 24.0),
|
||||
child: topGreeter,
|
||||
),
|
||||
child: topGreeter,
|
||||
);
|
||||
} else {
|
||||
return Center(
|
||||
|
Reference in New Issue
Block a user