Advertisement
Guest User

Untitled

a guest
Mar 17th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.63 KB | None | 0 0
  1. @override
  2.   Widget build(BuildContext context) {
  3.     return Container(
  4.       child: StreamBuilder(
  5.         stream: blocConditions.conditions,
  6.         builder: (context, AsyncSnapshot<ConditionsModel> snapshot){
  7.           if(snapshot.hasError)
  8.             return Center(child: Text('Hubo un error al recibir los datos'),);
  9.           switch (snapshot.connectionState){
  10.             case ConnectionState.waiting:
  11.               return Center(
  12.                   child: Column(
  13.                     mainAxisAlignment: MainAxisAlignment.center,
  14.                     crossAxisAlignment: CrossAxisAlignment.center,
  15.                     children: <Widget>[
  16.                       Text('Sin conexión a Internet'),
  17.                       FlatButton.icon(
  18.                         icon: Icon(Icons.refresh),
  19.                         label: Text(''),
  20.                         onPressed: fetchData,
  21.                       )
  22.                     ],
  23.                   )
  24.               );
  25.             case ConnectionState.active:
  26.               return Container(
  27.                 color: snapshot.data.current.isDay == 1 ? Colors.white70 : Colors.grey[700],
  28.                 child: ListView(
  29.                   children: <Widget>[
  30.                     WeatherConditions(data:snapshot.data),
  31.                     WeatherForecast(data: snapshot.data)
  32.                   ],
  33.                 ),
  34.               );
  35.             case ConnectionState.done:
  36.               return Text('Done');
  37.             case ConnectionState.none:
  38.               return Text('NONE');
  39.           }
  40.           return Center(child: CircularProgressIndicator());
  41.         },
  42.       ),
  43.     );
  44.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement