Skip to content

Commit

Permalink
Fix null reference bug
Browse files Browse the repository at this point in the history
  • Loading branch information
renefloor committed Jul 3, 2023
1 parent c8a087a commit 7d34e34
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion flutter_cache_manager/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void main() {
CacheManager.logLevel = CacheManagerLogLevel.verbose;
}

const url = 'https://blurha.sh/assets/images/img1.jpg';
const url = 'https://picsum.photos/200/300';

/// Example [Widget] showing the functionalities of flutter_cache_manager
class CacheManagerPage extends StatefulWidget {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class DownloadPage extends StatelessWidget {
);
} else if (loading) {
body = p_i.ProgressIndicator(
progress: snapshot.data as DownloadProgress,
progress: snapshot.data as DownloadProgress?,
);
} else {
body = FileInfoWidget(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import 'package:flutter_cache_manager/flutter_cache_manager.dart';

/// A [Widget] showing all available information about the downloaded file
class FileInfoWidget extends StatelessWidget {
final FileInfo? fileInfo;
final FileInfo fileInfo;
final VoidCallback clearCache;
final VoidCallback removeFile;

const FileInfoWidget({
required this.clearCache,
required this.removeFile,
this.fileInfo,
required this.fileInfo,
super.key,
});

Expand All @@ -20,20 +20,19 @@ class FileInfoWidget extends StatelessWidget {
children: <Widget>[
ListTile(
title: const Text('Original URL'),
subtitle: Text(fileInfo?.originalUrl ?? ''),
subtitle: Text(fileInfo.originalUrl ?? ''),
),
ListTile(
title: const Text('Local file path'),
subtitle: Text(fileInfo.file.path ?? ''),
),
if (fileInfo?.file != null)
ListTile(
title: const Text('Local file path'),
subtitle: Text(fileInfo?.file.path ?? ''),
),
ListTile(
title: const Text('Loaded from'),
subtitle: Text(fileInfo?.source.toString() ?? ''),
subtitle: Text(fileInfo.source.toString() ?? ''),
),
ListTile(
title: const Text('Valid Until'),
subtitle: Text(fileInfo?.validTill.toIso8601String() ?? ''),
subtitle: Text(fileInfo.validTill.toIso8601String() ?? ''),
),
Padding(
padding: const EdgeInsets.all(10),
Expand Down

0 comments on commit 7d34e34

Please sign in to comment.