bbs_list.dart 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. import 'package:flutter/material.dart';
  2. import '../models/bbs.dart';
  3. import '../constants.dart';
  4. class BbsListView extends StatefulWidget {
  5. final String type;
  6. final String page;
  7. final String size;
  8. BbsListView({Key key,
  9. this.type,
  10. this.page,
  11. this.size
  12. }) : super(key: key);
  13. @override
  14. _BbsListViewState createState() => _BbsListViewState();
  15. }
  16. class _BbsListViewState extends State<BbsListView> {
  17. @override
  18. void initState() {
  19. // TODO: implement initState
  20. super.initState();
  21. albumBloc.bbs(widget.type,widget.page,widget.size);
  22. }
  23. @override
  24. void dispose() {
  25. // TODO: implement dispose
  26. super.dispose();
  27. }
  28. @override
  29. Widget build(BuildContext context) {
  30. return StreamBuilder(
  31. stream: albumBloc.bbsList,
  32. builder: (context, snapshot) {
  33. if (!snapshot.hasData) {
  34. return Center(
  35. child: CircularProgressIndicator(),
  36. );
  37. }
  38. return ListView.separated(
  39. itemCount: snapshot.data.result.length,
  40. separatorBuilder: (BuildContext context, int index) => Divider(thickness: 0.2,color: Colors.grey,height: 0.2,),
  41. itemBuilder: (BuildContext context, int index) {
  42. return ExpansionTile(
  43. title: Text(snapshot.data.result[index].title,),
  44. children: [
  45. Divider(),
  46. ListTile(
  47. title: Text(snapshot.data.result[index].content,style: TextStyle(fontSize: 14),),
  48. )
  49. ],
  50. );
  51. },
  52. );
  53. },
  54. );
  55. }
  56. }