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();
|
_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}) {
|
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
|
? scrollThumb
|
||||||
: Row(
|
: Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
|
|
@ -39,9 +39,9 @@ class _FullscreenOverlayState extends State<FullscreenOverlay> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var viewInsets = MediaQuery.of(context).viewInsets;
|
final viewInsets = MediaQuery.of(context).viewInsets;
|
||||||
var date = ImageEntry.getBestDate(entry);
|
final date = ImageEntry.getBestDate(entry);
|
||||||
var subRowConstraints = BoxConstraints(maxWidth: 400);
|
final subRowConstraints = BoxConstraints(maxWidth: 400);
|
||||||
return IgnorePointer(
|
return IgnorePointer(
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: EdgeInsets.all(8.0).add(EdgeInsets.only(bottom: viewInsets.bottom)),
|
padding: EdgeInsets.all(8.0).add(EdgeInsets.only(bottom: viewInsets.bottom)),
|
||||||
|
|
|
@ -29,7 +29,7 @@ class ImageFullscreenPageState extends State<ImageFullscreenPage> {
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.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);
|
_currentPage = max(0, index);
|
||||||
_pageController = PageController(initialPage: _currentPage);
|
_pageController = PageController(initialPage: _currentPage);
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ class ImageFullscreenPageState extends State<ImageFullscreenPage> {
|
||||||
PhotoViewGallery.builder(
|
PhotoViewGallery.builder(
|
||||||
itemCount: entries.length,
|
itemCount: entries.length,
|
||||||
builder: (context, index) {
|
builder: (context, index) {
|
||||||
var entry = entries[index];
|
final entry = entries[index];
|
||||||
return PhotoViewGalleryPageOptions(
|
return PhotoViewGalleryPageOptions(
|
||||||
imageProvider: FileImage(File(entry['path'])),
|
imageProvider: FileImage(File(entry['path'])),
|
||||||
heroTag: entry['uri'],
|
heroTag: entry['uri'],
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
class ImageEntry {
|
class ImageEntry {
|
||||||
static DateTime getBestDate(Map entry) {
|
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);
|
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);
|
if (dateModifiedSecs != null && dateModifiedSecs > 0) return DateTime.fromMillisecondsSinceEpoch(dateModifiedSecs * 1000);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
static DateTime getDayTaken(Map entry) {
|
static DateTime getDayTaken(Map entry) {
|
||||||
var d = getBestDate(entry);
|
final d = getBestDate(entry);
|
||||||
return d == null ? null : DateTime(d.year, d.month, d.day);
|
return d == null ? null : DateTime(d.year, d.month, d.day);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ class ThumbnailState extends State<Thumbnail> {
|
||||||
}
|
}
|
||||||
|
|
||||||
initByteLoader() {
|
initByteLoader() {
|
||||||
var dim = (widget.extent * widget.devicePixelRatio).round();
|
final dim = (widget.extent * widget.devicePixelRatio).round();
|
||||||
_byteLoader = ImageFetcher.getImageBytes(widget.entry, dim, dim);
|
_byteLoader = ImageFetcher.getImageBytes(widget.entry, dim, dim);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,9 +58,9 @@ class ThumbnailState extends State<Thumbnail> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
var isVideo = mimeType.startsWith(MimeTypes.MIME_VIDEO);
|
final isVideo = mimeType.startsWith(MimeTypes.MIME_VIDEO);
|
||||||
var isGif = mimeType == MimeTypes.MIME_GIF;
|
final isGif = mimeType == MimeTypes.MIME_GIF;
|
||||||
var iconSize = widget.extent / 4;
|
final iconSize = widget.extent / 4;
|
||||||
return Container(
|
return Container(
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border.all(
|
border: Border.all(
|
||||||
|
@ -71,7 +71,7 @@ class ThumbnailState extends State<Thumbnail> {
|
||||||
child: FutureBuilder(
|
child: FutureBuilder(
|
||||||
future: _byteLoader,
|
future: _byteLoader,
|
||||||
builder: (futureContext, AsyncSnapshot<Uint8List> snapshot) {
|
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(
|
return Stack(
|
||||||
alignment: AlignmentDirectional.bottomStart,
|
alignment: AlignmentDirectional.bottomStart,
|
||||||
children: [
|
children: [
|
||||||
|
@ -81,7 +81,7 @@ class ThumbnailState extends State<Thumbnail> {
|
||||||
// during hero animation back from a fullscreen image,
|
// 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)
|
// 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
|
// 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(
|
return Container(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
constraints: BoxConstraints.tight(Size(dim, dim)),
|
constraints: BoxConstraints.tight(Size(dim, dim)),
|
||||||
|
|
|
@ -60,19 +60,18 @@ class SectionSliver extends StatelessWidget {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
// debugPrint('$runtimeType build with sectionKey=$sectionKey');
|
// debugPrint('$runtimeType build with sectionKey=$sectionKey');
|
||||||
var columnCount = 4;
|
final columnCount = 4;
|
||||||
var mediaQuery = MediaQuery.of(context);
|
|
||||||
|
|
||||||
return SliverStickyHeader(
|
return SliverStickyHeader(
|
||||||
header: DaySectionHeader(date: sectionKey),
|
header: DaySectionHeader(date: sectionKey),
|
||||||
sliver: SliverGrid(
|
sliver: SliverGrid(
|
||||||
delegate: SliverChildBuilderDelegate(
|
delegate: SliverChildBuilderDelegate(
|
||||||
(context, index) {
|
(sliverContext, index) {
|
||||||
var sectionEntries = sections[sectionKey];
|
final sectionEntries = sections[sectionKey];
|
||||||
if (index >= sectionEntries.length) return null;
|
if (index >= sectionEntries.length) return null;
|
||||||
var entry = sectionEntries[index];
|
final entry = sectionEntries[index];
|
||||||
|
final mediaQuery = MediaQuery.of(sliverContext);
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
onTap: () => _showFullscreen(context, entry),
|
onTap: () => _showFullscreen(sliverContext, entry),
|
||||||
child: Thumbnail(
|
child: Thumbnail(
|
||||||
entry: entry,
|
entry: entry,
|
||||||
extent: mediaQuery.size.width / columnCount,
|
extent: mediaQuery.size.width / columnCount,
|
||||||
|
|
Loading…
Reference in a new issue