|
@@ -11,9 +11,9 @@ import 'package:flutter_osc/widgets/CommonEndLine.dart';
|
|
|
// 动弹详情
|
|
|
|
|
|
class TweetDetailPage extends StatefulWidget {
|
|
|
- Map<String, dynamic> tweetData;
|
|
|
+ Map<String, dynamic>? tweetData;
|
|
|
|
|
|
- TweetDetailPage({Key key, this.tweetData}):super(key: key);
|
|
|
+ TweetDetailPage({Key? key, this.tweetData}):super(key: key);
|
|
|
|
|
|
@override
|
|
|
State<StatefulWidget> createState() {
|
|
@@ -23,8 +23,8 @@ class TweetDetailPage extends StatefulWidget {
|
|
|
|
|
|
class TweetDetailPageState extends State<TweetDetailPage> {
|
|
|
|
|
|
- Map<String, dynamic> tweetData;
|
|
|
- List commentList;
|
|
|
+ Map<String, dynamic>? tweetData;
|
|
|
+ List? commentList;
|
|
|
RegExp regExp1 = RegExp("</.*>");
|
|
|
RegExp regExp2 = RegExp("<.*>");
|
|
|
TextStyle subtitleStyle = TextStyle(
|
|
@@ -39,7 +39,7 @@ class TweetDetailPageState extends State<TweetDetailPage> {
|
|
|
ScrollController _controller = ScrollController();
|
|
|
TextEditingController _inputController = TextEditingController();
|
|
|
|
|
|
- TweetDetailPageState({Key key, this.tweetData});
|
|
|
+ TweetDetailPageState({Key? key, this.tweetData});
|
|
|
|
|
|
// 获取动弹的回复
|
|
|
getReply(bool isLoadMore) {
|
|
@@ -50,7 +50,7 @@ class TweetDetailPageState extends State<TweetDetailPage> {
|
|
|
return;
|
|
|
}
|
|
|
Map<String, String> params = Map();
|
|
|
- var id = this.tweetData['id'];
|
|
|
+ var id = this.tweetData!['id'];
|
|
|
params['id'] = '$id';
|
|
|
params['catalog'] = '3';// 3是动弹评论
|
|
|
params['access_token'] = token;
|
|
@@ -67,9 +67,9 @@ class TweetDetailPageState extends State<TweetDetailPage> {
|
|
|
} else {
|
|
|
// 加载更多数据
|
|
|
List list = [];
|
|
|
- list.addAll(commentList);
|
|
|
+ list.addAll(commentList!);
|
|
|
list.addAll(json.decode(data)['commentList']);
|
|
|
- if (list.length >= tweetData['commentCount']) {
|
|
|
+ if (list.length >= tweetData!['commentCount']) {
|
|
|
list.add(Constants.END_LINE_TAG);
|
|
|
}
|
|
|
commentList = list;
|
|
@@ -88,7 +88,7 @@ class TweetDetailPageState extends State<TweetDetailPage> {
|
|
|
_controller.addListener(() {
|
|
|
var max = _controller.position.maxScrollExtent;
|
|
|
var pixels = _controller.position.pixels;
|
|
|
- if (max == pixels && commentList.length < tweetData['commentCount']) {
|
|
|
+ if (max == pixels && commentList!.length < tweetData!['commentCount']) {
|
|
|
// scroll to end, load next page
|
|
|
curPage++;
|
|
|
getReply(true);
|
|
@@ -101,7 +101,7 @@ class TweetDetailPageState extends State<TweetDetailPage> {
|
|
|
var _body = commentList == null ? Center(
|
|
|
child: CircularProgressIndicator(),
|
|
|
) : ListView.builder(
|
|
|
- itemCount: commentList.length == 0 ? 1 : commentList.length * 2,
|
|
|
+ itemCount: commentList!.length == 0 ? 1 : commentList!.length * 2,
|
|
|
itemBuilder: renderListItem,
|
|
|
controller: _controller,
|
|
|
);
|
|
@@ -125,7 +125,7 @@ class TweetDetailPageState extends State<TweetDetailPage> {
|
|
|
|
|
|
Widget renderListItem(BuildContext context, int i) {
|
|
|
if (i == 0) {
|
|
|
- return getTweetView(this.tweetData);
|
|
|
+ return getTweetView(this.tweetData!);
|
|
|
}
|
|
|
i -= 1;
|
|
|
if (i.isOdd) {
|
|
@@ -137,7 +137,7 @@ class TweetDetailPageState extends State<TweetDetailPage> {
|
|
|
|
|
|
// 渲染评论列表
|
|
|
_renderCommentRow(context, i) {
|
|
|
- var listItem = commentList[i];
|
|
|
+ var listItem = commentList![i];
|
|
|
if (listItem is String && listItem == Constants.END_LINE_TAG) {
|
|
|
return CommonEndLine();
|
|
|
}
|
|
@@ -200,8 +200,8 @@ class TweetDetailPageState extends State<TweetDetailPage> {
|
|
|
String title;
|
|
|
String authorId;
|
|
|
if (isMainFloor) {
|
|
|
- title = "@${tweetData['author']}";
|
|
|
- authorId = "${tweetData['authorid']}";
|
|
|
+ title = "@${tweetData!['author']}";
|
|
|
+ authorId = "${tweetData!['authorid']}";
|
|
|
} else {
|
|
|
title = "@${data['commentAuthor']}";
|
|
|
authorId = "${data['commentAuthorId']}";
|
|
@@ -269,10 +269,10 @@ class TweetDetailPageState extends State<TweetDetailPage> {
|
|
|
DataUtils.isLogin().then((isLogin) {
|
|
|
if (isLogin) {
|
|
|
DataUtils.getAccessToken().then((token) {
|
|
|
- Map<String, String> params = Map();
|
|
|
+ Map<String, String?> params = Map();
|
|
|
params['access_token'] = token;
|
|
|
- params['id'] = "${tweetData['id']}";
|
|
|
- print("id: ${tweetData['id']}");
|
|
|
+ params['id'] = "${tweetData!['id']}";
|
|
|
+ print("id: ${tweetData!['id']}");
|
|
|
params['catalog'] = "3";
|
|
|
params['content'] = replyStr;
|
|
|
params['authorid'] = "$authorId";
|
|
@@ -355,7 +355,7 @@ class TweetDetailPageState extends State<TweetDetailPage> {
|
|
|
child: contentRow,
|
|
|
),
|
|
|
];
|
|
|
- String imgSmall = listItem['imgSmall'];
|
|
|
+ String? imgSmall = listItem['imgSmall'];
|
|
|
if (imgSmall != null && imgSmall.length > 0) {
|
|
|
// 动弹中有图片
|
|
|
List<String> list = imgSmall.split(",");
|
|
@@ -370,7 +370,7 @@ class TweetDetailPageState extends State<TweetDetailPage> {
|
|
|
List<Widget> imgList = [];
|
|
|
List rows = [];
|
|
|
num len = imgUrlList.length;
|
|
|
- for (var row = 0; row < getRow(len); row++) {
|
|
|
+ for (var row = 0; row < getRow(len as int); row++) {
|
|
|
List<Widget> rowArr = [];
|
|
|
for (var col = 0; col < 3; col++) {
|
|
|
num index = row * 3 + col;
|
|
@@ -379,7 +379,7 @@ class TweetDetailPageState extends State<TweetDetailPage> {
|
|
|
if (index < len) {
|
|
|
rowArr.add(Padding(
|
|
|
padding: const EdgeInsets.all(2.0),
|
|
|
- child: Image.network(imgUrlList[index], width: cellWidth, height: cellWidth),
|
|
|
+ child: Image.network(imgUrlList[index as int], width: cellWidth, height: cellWidth),
|
|
|
));
|
|
|
}
|
|
|
}
|