import 'package:audioplayers/audioplayers.dart'; import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutterappfuyou/code/base/YSNetWorking.dart'; import 'base/YSBase.dart'; class YSQuestionDetail extends StatefulWidget { final bool isPolicy; final int questionId; const YSQuestionDetail({Key key, this.questionId,this.isPolicy}) : super(key: key); @override _YSQuestionDetailState createState() => _YSQuestionDetailState(); } class _YSQuestionDetailState extends State { Map _infoData; AudioPlayer audioPlayer = AudioPlayer(); @override void initState() { Future.delayed(Duration(seconds: 0)).then((value){ widget.isPolicy==false?_getQuestionDetailData():_getPolicyDetailData(); }); super.initState(); } @override Widget build(BuildContext context) { return YSBase( ystitle: '问题详情', yschild: Container( decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.only(topLeft: Radius.circular(20),topRight: Radius.circular(20)) ), child: _infoData==null?Container():SingleChildScrollView( padding: EdgeInsets.only(left: 15,right: 15,top: 20,bottom: 15), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ Container( margin: EdgeInsets.only(bottom: 15), child: Row( children: [ Container( height: 35, width: 35, decoration: BoxDecoration( color: Color(0xFFF5F3F0), borderRadius: BorderRadius.all(Radius.circular(17.5)), image: DecorationImage(image: NetworkImage('${_infoData['doctor_avatar']}'),fit: BoxFit.fill) ), ), Container( margin: EdgeInsets.only(left: 10), width: MediaQuery.of(context).size.width-85, child: Text('${_infoData['doctor_name']}医生 解答了该问题',style: TextStyle(fontSize: 14,color: Color(0xFF666666)),overflow: TextOverflow.ellipsis,), ) ], ), ), Container( child: Text('标题:${_infoData['question_title']}',style: TextStyle(fontSize: 14,color: Color(0xFF292929))), ), Container( margin: EdgeInsets.only(bottom: 15,top: 15), child: Text('问:${_infoData['question_body']}',style: TextStyle(fontSize: 14,color: Color(0xFF292929)),), ), Container( width: MediaQuery.of(context).size.width-40, child: _infoData['answer_type']=='voice'?Row( children: [ Text('医生解答:',style: TextStyle(fontSize: 14,color: Color(0xFF428B8D)),overflow: TextOverflow.ellipsis,), Container( height: 26, width: 59, decoration: BoxDecoration( color: Color(0xFFF5F3F0), borderRadius: BorderRadius.all(Radius.circular(4)) ), alignment: Alignment.center, child: Stack( children: [ Row( children: [ Container( child: Image.asset('lib/images/voice2.png'), height: 15, width: 15, margin: EdgeInsets.only(left: 10,right: 5), ), Text('4',style: TextStyle(fontSize: 14,color: Color(0xFF428B8D)),overflow: TextOverflow.ellipsis,), ], ) ], ), ) ], ):Text('医生解答:${(_infoData['answer_body'])??''}',style: TextStyle(fontSize: 14,color: Color(0xFF428B8D)),), ), Container( margin: EdgeInsets.only(top: 15), child: Text('${_infoData['question_time']??_infoData['created_at']}',style: TextStyle(fontSize: 12,color: Color(0xFF808080))), ) ], ), ), ), ); } _getQuestionDetailData() async{ Map dict = await ysRequestHttp(context, requestType.post, 'question/info', {'question_id':widget.questionId}); if(dict!=null){ setState(() { _infoData = dict['data']; }); } } _getPolicyDetailData() async{ Map dict = await ysRequestHttp(context, requestType.get, 'policy/info', {'id':widget.questionId}); if(dict!=null){ setState(() { _infoData = dict['data']; }); } } play() async { audioPlayer.play(UrlSource('')); // if (result == 1) { // // success // print('play success'); // } else { // print('play failed'); // } } }