sliver

import 'package:flutter/material.dart';
import 'package:xxx/bloc/bloc.dart';
import 'package:xxx/model/model.dart';

class ArticlePage extends StatelessWidget {
ArticlePage(this.bloc);

final ArticleBloc bloc;

@override
Widget build(BuildContext context) {
bloc.addContent();
return StreamBuilder(
stream: bloc.dataBloc.stream,
builder: (context, snapshot) {
if (snapshot.hasData) {
ContentModel content = snapshot.data;
print(content.mainPost);
return Scaffold(
appBar: AppBar(
title: Text(content.title, style: TextStyle(fontSize: 14.0),),
),
body: CustomScrollView(
slivers: <Widget>[

SliverPadding(
padding: EdgeInsets.all(8.0),
sliver: SliverGrid(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
mainAxisSpacing: 10.0,
crossAxisSpacing: 10.0,
childAspectRatio: 4.0,
),
delegate: SliverChildBuilderDelegate(
(context, int index) {
return Container(
color: Colors.grey,
child: Text('hello'),
);
},
childCount: 20,
),
),
),

SliverFixedExtentList(
itemExtent: 50.0,
delegate: SliverChildBuilderDelegate((context, int index) {
return Container(
color: Colors.blueGrey,
child: Text('hello2'),
);
}),
),
],
),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.add),
onPressed: (){}
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,
bottomNavigationBar: BottomNavigationBar(
items: [
BottomNavigationBarItem(
icon: Icon(Icons.home),
title: Text('home')
),
BottomNavigationBarItem(
icon: Icon(Icons.map),
title: Text('My')
),
]
),
);
} else {
return Scaffold(
appBar: AppBar(
title: Text('has no data'),
),
body: Text('has no data'),
);
}
},
);
}
}
//
//class ArticlePage extends StatelessWidget {
// ArticlePage(this.bloc);
//
// final ArticleBloc bloc;
//
// @override
// Widget build(BuildContext context) {
// bloc.addContent();
// return StreamBuilder(
// stream: bloc.dataBloc.stream,
// builder: (context, snapshot) {
// if (snapshot.hasData) {
// ContentModel content = snapshot.data;
// print(content.mainPost);
// return Scaffold(
// appBar: AppBar(
// title: Text(content.title),
// ),
// body: Column(
// children: <Widget>[
// //main area
// Text('post owner: ${content.owner}'),
// Text('post owner: ${content.ownerAvatar}'),
// Container(
// width: double.infinity,
// color: Colors.red,
// child: Column(
// children: content.mainPost,
// ),
// ),
// Text(content.mainPostTime),
// //replies
//
//
// ],
// ),
// );
// } else {
// return Scaffold(
// appBar: AppBar(
// title: Text('has no data'),
// ),
// body: Text('has no data'),
// );
// }
// },
// );
// }
//}

猜你喜欢

转载自www.cnblogs.com/pythonClub/p/10658703.html