article.dart 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import 'package:flutter/material.dart';
  2. import 'package:flutter_html/flutter_html.dart';
  3. import 'package:flutter_html/style.dart';
  4. import 'package:jmrh/constant/styles.dart';
  5. class Article extends StatefulWidget {
  6. Article({Key key}) : super(key: key);
  7. @override
  8. _ArticleState createState() => _ArticleState();
  9. }
  10. class _ArticleState extends State<Article> {
  11. @override
  12. Widget build(BuildContext context) {
  13. final Map<dynamic, dynamic> data =
  14. ModalRoute.of(context).settings.arguments;
  15. return Scaffold(
  16. appBar: AppBar(
  17. brightness: Brightness.light,
  18. iconTheme: IconTheme.of(context).copyWith(color: COLOR_TEXT_1),
  19. backgroundColor: Colors.white,
  20. elevation: 0,
  21. title: appbarTitle('文章详情'),
  22. centerTitle: true,
  23. leading: IconButton(
  24. icon: ImageIcon(
  25. AssetImage('img/nav_icon_return.png'),
  26. size: 28,
  27. ),
  28. onPressed: () {
  29. Navigator.pop(context);
  30. },
  31. ),
  32. actions: [
  33. IconButton(
  34. icon: ImageIcon(AssetImage('img/nav_icon_fenxiang_heise.png'),
  35. size: 28),
  36. tooltip: '分享',
  37. onPressed: () {},
  38. )
  39. ],
  40. ),
  41. body: CustomScrollView(
  42. slivers: [
  43. SliverToBoxAdapter(
  44. child: Container(
  45. margin: EdgeInsets.fromLTRB(16, 27, 16, 0),
  46. child: Text(data['title'],
  47. style: TextStyle(
  48. fontSize: 20,
  49. color: COLOR_TEXT_1,
  50. fontWeight: FontWeight.bold)),
  51. ),
  52. ),
  53. SliverToBoxAdapter(
  54. child: Container(
  55. margin: EdgeInsets.fromLTRB(16, 15, 16, 15),
  56. child: Text(
  57. '发布时间:${data['time']}',
  58. style: TextStyle(color: COLOR_TEXT_3, fontSize: 13),
  59. ),
  60. ),
  61. ),
  62. SliverToBoxAdapter(
  63. child: Html(
  64. data: data['detail'],
  65. style: {'body': Style(padding: EdgeInsets.all(16))},
  66. ),
  67. )
  68. ],
  69. ),
  70. );
  71. }
  72. }