From 299a95ea457110d1d7d188a75ef0b464ff02a9df Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Thu, 10 Mar 2022 20:28:07 +0100 Subject: [PATCH] Continue to fix issues --- lib/lists/comments_list.dart | 17 ++--------------- lib/lists/friends_list.dart | 17 ++--------------- lib/lists/posts_list.dart | 20 +++----------------- lib/ui/widgets/posts_list_widget.dart | 7 +------ 4 files changed, 8 insertions(+), 53 deletions(-) diff --git a/lib/lists/comments_list.dart b/lib/lists/comments_list.dart index 3c65d31..a47651e 100644 --- a/lib/lists/comments_list.dart +++ b/lib/lists/comments_list.dart @@ -1,5 +1,4 @@ -import 'dart:collection'; - +import 'package:comunic/lists/abstract_list.dart'; import 'package:comunic/models/comment.dart'; /// Comments list @@ -8,19 +7,7 @@ import 'package:comunic/models/comment.dart'; /// /// @author Pierre HUBERT -class CommentsList extends ListBase { - List _list = []; - - int get length => _list.length; - - set length(int l) => _list.length = l; - - @override - Comment operator [](int index) => _list[index]; - - @override - void operator []=(int index, Comment value) => _list[index] = value; - +class CommentsList extends AbstractList { /// Get the list of users in this comments, as a set Set get usersID => map((f) => f.userID).toSet(); } diff --git a/lib/lists/friends_list.dart b/lib/lists/friends_list.dart index 6fe7eb9..ae654b1 100644 --- a/lib/lists/friends_list.dart +++ b/lib/lists/friends_list.dart @@ -1,24 +1,11 @@ -import 'dart:collection'; - +import 'package:comunic/lists/abstract_list.dart'; import 'package:comunic/models/friend.dart'; /// List of friends of the user /// /// @author Pierre HUBERT -class FriendsList extends ListBase { - List _list = []; - - int get length => _list.length; - - set length(int length) => _list.length = length; - - @override - Friend operator [](int index) => _list[index]; - - @override - void operator []=(int index, Friend value) => _list[index] = value; - +class FriendsList extends AbstractList { /// Get the ID of all the friends of the current user List get usersId => map((f) => f.id).toList(); } diff --git a/lib/lists/posts_list.dart b/lib/lists/posts_list.dart index d2fbc30..bc68617 100644 --- a/lib/lists/posts_list.dart +++ b/lib/lists/posts_list.dart @@ -1,5 +1,4 @@ -import 'dart:collection'; - +import 'package:comunic/lists/abstract_list.dart'; import 'package:comunic/models/post.dart'; /// Posts List @@ -8,19 +7,7 @@ import 'package:comunic/models/post.dart'; /// /// @author Pierre HUBERT -class PostsList extends ListBase { - List _list = []; - - int get length => _list.length; - - set length(int l) => _list.length = l; - - @override - Post operator [](int index) => _list[index]; - - @override - void operator []=(int index, Post value) => _list[index] = value; - +class PostsList extends AbstractList { // Get the list of users ID in this set Set get usersID { Set set = Set(); @@ -49,8 +36,7 @@ class PostsList extends ListBase { /// Get the ID of the oldest post of this list. Returns 0 if the list is empty int get oldestID { - if(isEmpty) - return 0; + if (isEmpty) return 0; return this.elementAt(length - 1).id; } diff --git a/lib/ui/widgets/posts_list_widget.dart b/lib/ui/widgets/posts_list_widget.dart index b2989e7..9985209 100644 --- a/lib/ui/widgets/posts_list_widget.dart +++ b/lib/ui/widgets/posts_list_widget.dart @@ -41,12 +41,7 @@ class PostsListWidget extends StatefulWidget { this.getOlder, this.topWidgets, this.disablePullToRefresh = false, - }) : assert(getPostsList != null), - assert(showPostsTarget != null), - assert(buildListView != null), - assert(userNamesClickable != null), - assert(disablePullToRefresh != null), - super(key: key); + }) : super(key: key); @override State createState() => PostsListWidgetState();