Merge pull request #733 from GetStream/hotfix/mediaListView

fix(ui): use createdAt to sort media (the default value is updatedAt)
This commit is contained in:
Salvatore Giordano
2021-10-13 09:43:25 +02:00
committed by GitHub
3 changed files with 25 additions and 14 deletions
@@ -2,6 +2,10 @@
- Updated Dart SDK constraints to `>=2.14.0 <3.0.0`
🐞 Fixed
- [[#491]](https://github.com/GetStream/stream-chat-flutter/issues/491): Fix `MediaListView` showing media in wrong order.
✅ Added
- `MessageListViewThemeData` now accepts a `DecorationImage` as a background image for `MessageListView`.
@@ -1,5 +1,6 @@
import 'dart:ui' as ui;
import 'package:collection/collection.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
@@ -145,21 +146,24 @@ class _MediaListViewState extends State<MediaListView> {
}
Future<void> _getMedia() async {
final assetList = await PhotoManager.getAssetPathList().then((value) {
if (value.isNotEmpty) {
return value.singleWhere((element) => element.isAll);
}
});
final assetList = (await PhotoManager.getAssetPathList(
filterOption: FilterOptionGroup(
orders: [
const OrderOption(
// ignore: avoid_redundant_argument_values
type: OrderOptionType.createDate,
),
],
),
onlyAll: true,
))
.firstOrNull;
if (assetList == null) {
return;
}
final media = await assetList?.getAssetListPaged(_currentPage, 50);
final media = await assetList.getAssetListPaged(_currentPage, 50);
if (media.isNotEmpty) {
if (media?.isNotEmpty == true) {
setState(() {
_media.addAll(media);
_media.addAll(media!);
});
}
++_currentPage;
@@ -118,8 +118,11 @@ class MessageListViewThemeData with Diagnosticable {
properties
..add(ColorProperty('backgroundColor', backgroundColor))
..add(
DiagnosticsProperty<DecorationImage>('backgroundImage', backgroundImage,
defaultValue: null),
DiagnosticsProperty<DecorationImage>(
'backgroundImage',
backgroundImage,
defaultValue: null,
),
);
}
}