Fix BadElement: use firstOrNull instead of first

This commit is contained in:
Neeraj Gupta 2022-11-22 14:13:40 +05:30
parent 49c3922a1f
commit 9f84a49952
No known key found for this signature in database
GPG key ID: 3C5A1684DC1729E1
4 changed files with 13 additions and 17 deletions

View file

@ -0,0 +1 @@

View file

@ -2,6 +2,7 @@
import 'dart:convert';
import 'package:collection/collection.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
@ -59,7 +60,7 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {
@override
Widget build(BuildContext context) {
final enteColorScheme = getEnteColorScheme(context);
final PublicURL url = widget.collection?.publicURLs?.first;
final PublicURL url = widget.collection?.publicURLs?.firstOrNull;
return Scaffold(
backgroundColor: Theme.of(context).backgroundColor,
appBar: AppBar(
@ -128,9 +129,9 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {
menuItemColor: getEnteColorScheme(context).fillFaint,
pressedColor: getEnteColorScheme(context).fillFaint,
trailingSwitch: Switch.adaptive(
value:
widget.collection.publicURLs?.first?.enableDownload ??
true,
value: widget.collection.publicURLs?.firstOrNull
?.enableDownload ??
true,
onChanged: (value) async {
if (!value) {
final choice = await showChoiceDialog(
@ -177,8 +178,8 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {
menuItemColor: getEnteColorScheme(context).fillFaint,
pressedColor: getEnteColorScheme(context).fillFaint,
trailingSwitch: Switch.adaptive(
value: widget
.collection.publicURLs?.first?.passwordEnabled ??
value: widget.collection.publicURLs?.firstOrNull
?.passwordEnabled ??
false,
onChanged: (enablePassword) async {
if (enablePassword) {
@ -471,7 +472,8 @@ class _ManageSharedLinkWidgetState extends State<ManageSharedLinkWidget> {
}
Text _getLinkExpiryTimeWidget() {
final int validTill = widget.collection.publicURLs?.first?.validTill ?? 0;
final int validTill =
widget.collection.publicURLs?.firstOrNull?.validTill ?? 0;
if (validTill == 0) {
return const Text(
'Never',

View file

@ -2,6 +2,7 @@
import 'dart:async';
import 'package:collection/collection.dart';
import 'package:fast_base58/fast_base58.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
@ -44,7 +45,7 @@ class _ShareCollectionPageState extends State<ShareCollectionPage> {
@override
Widget build(BuildContext context) {
_sharees = widget.collection.sharees;
_sharees = widget.collection.sharees ?? [];
final children = <Widget>[];
children.add(
MenuSectionTitle(
@ -83,7 +84,7 @@ class _ShareCollectionPageState extends State<ShareCollectionPage> {
final bool hasUrl = widget.collection.publicURLs?.isNotEmpty ?? false;
final bool hasExpired =
widget.collection.publicURLs?.first?.isExpired ?? false;
widget.collection?.publicURLs?.firstOrNull?.isExpired ?? false;
children.addAll([
const SizedBox(
height: 24,

View file

@ -337,14 +337,6 @@ class _GalleryAppBarWidgetState extends State<GalleryAppBarWidget> {
ShareCollectionPage(collection),
),
);
/*return showDialog<void>(
context: context,
builder: (BuildContext context) {
return SharingDialog(
collection,
);
},
);*/
} catch (e, s) {
_logger.severe(e, s);
await dialog.hide();