SHARE
TWEET

Untitled

a guest Mar 20th, 2019 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class HomePage extends StatelessWidget {
  2.   HomeBloc _bloc;
  3.  
  4.   @override
  5.   Widget build(BuildContext context) {
  6.     _bloc = BlocProvider.of<HomeBloc>(context);
  7.     return Scaffold(
  8.       appBar: AppBar(title: Text('Flutter Ready to Go')),
  9.       body: StreamBuilder(
  10.           stream: _bloc.personStream,
  11.           builder: (context, AsyncSnapshot<Person> snapshot) {
  12.             if(!snapshot.hasData) return Center(child: CircularProgressIndicator());
  13.             final person = snapshot.data;
  14.             return _buildPersonInfo(person);
  15.           }
  16.       ),
  17.     );
  18.   }
  19.  
  20.   Widget _buildPersonInfo(Person person) {
  21.     return Column(
  22.       crossAxisAlignment: CrossAxisAlignment.start,
  23.       mainAxisSize: MainAxisSize.max,
  24.       children: <Widget>[
  25.         Row(
  26.           mainAxisAlignment: MainAxisAlignment.center,
  27.           children: <Widget>[
  28.             _buildText("Api URL: ${person.apiUrl}", 22.0)
  29.           ],
  30.         ),
  31.         _buildText("Name: ${person.name} ${person.lastName}", 16.0),
  32.         _buildText("Github: ${person.github}", 16.0),
  33.         _buildText("Twitter: ${person.twitter}", 16.0),
  34.         _buildText("Website: ${person.website}", 16.0),
  35.       ],
  36.     );
  37.   }
  38.  
  39.   Widget _buildText(String text, double fontSize) {
  40.     return Padding(
  41.       padding: EdgeInsets.only(top: 20.0, right: 10.0, left: 10.0),
  42.       child: Text(text,
  43.           style: TextStyle(
  44.               fontWeight: FontWeight.bold,
  45.               color: Colors.grey[800],
  46.               fontSize: fontSize
  47.           )
  48.       ),
  49.     );
  50.   }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top