123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- import 'package:eitc_erm_app/utils/Component.dart';
- import 'package:eitc_erm_app/utils/Constants.dart';
- import 'package:eitc_erm_app/utils/logger.dart';
- import 'package:flutter/material.dart';
- import 'package:html/parser.dart' as parser;
- import 'package:http/http.dart' as http;
- import 'bean/normal_response3.dart';
- void main() {
- WidgetsFlutterBinding.ensureInitialized();
- runApp(Agreement());
- }
- class Agreement extends StatefulWidget {
- @override
- State<StatefulWidget> createState() => AgreementState();
- }
- class AgreementState extends State<Agreement> {
- ValueNotifier<dynamic> result = ValueNotifier(null);
- late Future<NormalResponse3?> _future;
- String strHtml = "";
- String strHtml1 = "";
- String strHtml2 = "";
- String strHtml3 = "";
- String strHtml4 = "";
- String strHtml5 = "";
- @override
- void initState() {
- super.initState();
- _future = fetchData();
- }
- Future<NormalResponse3?> fetchData() async {
- Map<String, String> headers = {
- 'token': Global.token,
- };
- final response =
- await http.get(Uri.parse('${Global.BaseUrl}api/user-notice'));
- if (response.statusCode == 200) {
- final json = decodeBodyToJson(response.bodyBytes);
- logd(json);
- NormalResponse3 mNormalResponse3 = new NormalResponse3.fromJson(json);
- if (mNormalResponse3.code == Global.responseSuccessCode) {
- int i = 0;
- parser.parse(mNormalResponse3.data).body?.children.forEach((element) {
- if (i == 0) {
- strHtml = element.text;
- i++;
- } else if (i == 1) {
- strHtml1 = element.text;
- i++;
- } else if (i == 2) {
- strHtml2 = element.text;
- i++;
- } else if (i == 3) {
- strHtml3 = element.text;
- i++;
- } else if (i == 4) {
- strHtml4 = element.text;
- i++;
- } else if (i == 5) {
- strHtml5 = element.text;
- i++;
- }
- });
- setState(() {});
- return mNormalResponse3;
- } else {
- Component.toast(mNormalResponse3.msg.toString(), 0);
- }
- return null;
- } else {
- Component.toast("出错了,请稍后再试!", 0);
- return null;
- }
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: new AppBar(
- title: new Text('用户协议',
- style: TextStyle(
- color: Colors.white,
- )),
- centerTitle: true,
- elevation: 0.5,
- backgroundColor: Global.StatusBarColor,
- leading: new IconButton(
- tooltip: '返回上一页',
- icon: const Icon(
- Icons.arrow_back_ios,
- color: Colors.white,
- ),
- onPressed: () {
- Navigator.of(context).pop();
- //_nextPage(-1);
- },
- ),
- ),
- body: SingleChildScrollView(
- child: Center(
- child: Padding(
- padding: const EdgeInsets.all(20),
- child: Column(children: [
- Center(
- child: Text(
- strHtml,
- style: const TextStyle(
- fontSize: 18,
- color: Colors.black,
- ),
- ),
- ),
- Text(
- strHtml1 + strHtml2 + strHtml3 + strHtml4 + strHtml5,
- style: const TextStyle(
- fontSize: 13,
- color: Colors.grey,
- ),
- ),
- ]))),
- ),
- );
- }
- }
|