use final where possible
This commit is contained in:
parent
5f9843ee1a
commit
16c43b46c9
6 changed files with 21 additions and 22 deletions
|
@ -128,7 +128,7 @@ class DraggableScrollbar extends StatefulWidget {
|
|||
_DraggableScrollbarState createState() => _DraggableScrollbarState();
|
||||
|
||||
static buildScrollThumbAndLabel({@required Widget scrollThumb, @required Color backgroundColor, @required Animation<double> thumbAnimation, @required Animation<double> labelAnimation, @required Text labelText, @required BoxConstraints labelConstraints, @required bool alwaysVisibleScrollThumb}) {
|
||||
var scrollThumbAndLabel = labelText == null
|
||||
final scrollThumbAndLabel = labelText == null
|
||||
? scrollThumb
|
||||
: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
|
|
|
@ -39,9 +39,9 @@ class _FullscreenOverlayState extends State<FullscreenOverlay> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var viewInsets = MediaQuery.of(context).viewInsets;
|
||||
var date = ImageEntry.getBestDate(entry);
|
||||
var subRowConstraints = BoxConstraints(maxWidth: 400);
|
||||
final viewInsets = MediaQuery.of(context).viewInsets;
|
||||
final date = ImageEntry.getBestDate(entry);
|
||||
final subRowConstraints = BoxConstraints(maxWidth: 400);
|
||||
return IgnorePointer(
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(8.0).add(EdgeInsets.only(bottom: viewInsets.bottom)),
|
||||
|
|
|
@ -29,7 +29,7 @@ class ImageFullscreenPageState extends State<ImageFullscreenPage> {
|
|||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
var index = entries.indexWhere((entry) => entry['uri'] == widget.initialUri);
|
||||
final index = entries.indexWhere((entry) => entry['uri'] == widget.initialUri);
|
||||
_currentPage = max(0, index);
|
||||
_pageController = PageController(initialPage: _currentPage);
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ class ImageFullscreenPageState extends State<ImageFullscreenPage> {
|
|||
PhotoViewGallery.builder(
|
||||
itemCount: entries.length,
|
||||
builder: (context, index) {
|
||||
var entry = entries[index];
|
||||
final entry = entries[index];
|
||||
return PhotoViewGalleryPageOptions(
|
||||
imageProvider: FileImage(File(entry['path'])),
|
||||
heroTag: entry['uri'],
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
class ImageEntry {
|
||||
static DateTime getBestDate(Map entry) {
|
||||
var dateTakenMillis = entry['sourceDateTakenMillis'] as int;
|
||||
final dateTakenMillis = entry['sourceDateTakenMillis'] as int;
|
||||
if (dateTakenMillis != null && dateTakenMillis > 0) return DateTime.fromMillisecondsSinceEpoch(dateTakenMillis);
|
||||
|
||||
var dateModifiedSecs = entry['dateModifiedSecs'] as int;
|
||||
final dateModifiedSecs = entry['dateModifiedSecs'] as int;
|
||||
if (dateModifiedSecs != null && dateModifiedSecs > 0) return DateTime.fromMillisecondsSinceEpoch(dateModifiedSecs * 1000);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
static DateTime getDayTaken(Map entry) {
|
||||
var d = getBestDate(entry);
|
||||
final d = getBestDate(entry);
|
||||
return d == null ? null : DateTime(d.year, d.month, d.day);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ class ThumbnailState extends State<Thumbnail> {
|
|||
}
|
||||
|
||||
initByteLoader() {
|
||||
var dim = (widget.extent * widget.devicePixelRatio).round();
|
||||
final dim = (widget.extent * widget.devicePixelRatio).round();
|
||||
_byteLoader = ImageFetcher.getImageBytes(widget.entry, dim, dim);
|
||||
}
|
||||
|
||||
|
@ -58,9 +58,9 @@ class ThumbnailState extends State<Thumbnail> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var isVideo = mimeType.startsWith(MimeTypes.MIME_VIDEO);
|
||||
var isGif = mimeType == MimeTypes.MIME_GIF;
|
||||
var iconSize = widget.extent / 4;
|
||||
final isVideo = mimeType.startsWith(MimeTypes.MIME_VIDEO);
|
||||
final isGif = mimeType == MimeTypes.MIME_GIF;
|
||||
final iconSize = widget.extent / 4;
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(
|
||||
|
@ -71,7 +71,7 @@ class ThumbnailState extends State<Thumbnail> {
|
|||
child: FutureBuilder(
|
||||
future: _byteLoader,
|
||||
builder: (futureContext, AsyncSnapshot<Uint8List> snapshot) {
|
||||
var bytes = (snapshot.connectionState == ConnectionState.done && !snapshot.hasError) ? snapshot.data : kTransparentImage;
|
||||
final bytes = (snapshot.connectionState == ConnectionState.done && !snapshot.hasError) ? snapshot.data : kTransparentImage;
|
||||
return Stack(
|
||||
alignment: AlignmentDirectional.bottomStart,
|
||||
children: [
|
||||
|
@ -81,7 +81,7 @@ class ThumbnailState extends State<Thumbnail> {
|
|||
// during hero animation back from a fullscreen image,
|
||||
// the image covers the whole screen (because of the 'fit' prop and the full screen hero constraints)
|
||||
// so we wrap the image to apply better constraints
|
||||
var dim = min(constraints.maxWidth, constraints.maxHeight);
|
||||
final dim = min(constraints.maxWidth, constraints.maxHeight);
|
||||
return Container(
|
||||
alignment: Alignment.center,
|
||||
constraints: BoxConstraints.tight(Size(dim, dim)),
|
||||
|
|
|
@ -60,19 +60,18 @@ class SectionSliver extends StatelessWidget {
|
|||
@override
|
||||
Widget build(BuildContext context) {
|
||||
// debugPrint('$runtimeType build with sectionKey=$sectionKey');
|
||||
var columnCount = 4;
|
||||
var mediaQuery = MediaQuery.of(context);
|
||||
|
||||
final columnCount = 4;
|
||||
return SliverStickyHeader(
|
||||
header: DaySectionHeader(date: sectionKey),
|
||||
sliver: SliverGrid(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(context, index) {
|
||||
var sectionEntries = sections[sectionKey];
|
||||
(sliverContext, index) {
|
||||
final sectionEntries = sections[sectionKey];
|
||||
if (index >= sectionEntries.length) return null;
|
||||
var entry = sectionEntries[index];
|
||||
final entry = sectionEntries[index];
|
||||
final mediaQuery = MediaQuery.of(sliverContext);
|
||||
return GestureDetector(
|
||||
onTap: () => _showFullscreen(context, entry),
|
||||
onTap: () => _showFullscreen(sliverContext, entry),
|
||||
child: Thumbnail(
|
||||
entry: entry,
|
||||
extent: mediaQuery.size.width / columnCount,
|
||||
|
|
Loading…
Reference in a new issue