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'),
// );
// }
// },
// );
// }
//}

转载于:https://www.cnblogs.com/pythonClub/p/10658703.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值