Skip to content

Commit

Permalink
Optimize Collections
Browse files Browse the repository at this point in the history
  • Loading branch information
神楽坂花火 committed Mar 23, 2020
1 parent 9071353 commit 3bee91f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions lib/pages/about.dart
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ class _AboutPageState extends State<AboutPage> {

Future<List<Picture>> _fetchData() async {
List<Picture> result = [];
List<String> ids = Settings.marked;
List<String> ids = Settings.marked.reversed.toList();
if (ids.isEmpty) {
return result;
}
Expand All @@ -359,7 +359,7 @@ class _AboutPageState extends State<AboutPage> {
}

for (int i = 0; i < ids.length; i++) {
result.add(await TujianApi.getDetails(ids[i]));
result.add((await TujianApi.getDetails(ids[i]))..marked = true);
}
AppModel.of(context).collections = result;
return result;
Expand Down
9 changes: 4 additions & 5 deletions lib/pages/details.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import 'dart:collection';
import 'dart:io';
import 'dart:math' as math;
import 'dart:typed_data';
Expand Down Expand Up @@ -414,13 +413,13 @@ class _DetailsPageState extends State<DetailsPage> {
} else {
data.marked = !data.marked;
}
HashSet<String> hashSet = HashSet.from(Settings.marked);
List<String> list = List.from(Settings.marked);
if (data.marked) {
hashSet.add(data.id);
list.add(data.id);
} else {
hashSet.remove(data.id);
list.remove(data.id);
}
Settings.marked = hashSet.toList();
Settings.marked = list.toList();
AppModel.of(context).collections = [];
setState(() {});
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: dailypics
description: A new Flutter application.
version: 2.1.4+200314
version: 2.1.6+200322

environment:
sdk: ">=2.3.0 <3.0.0"
Expand Down

0 comments on commit 3bee91f

Please sign in to comment.