mirror of
https://gitlab.com/nkming2/nc-photos.git
synced 2025-01-22 16:56:19 +01:00
Fix warnings on Binding.instance
This commit is contained in:
parent
3b537ec76d
commit
17838d0704
20 changed files with 30 additions and 32 deletions
|
@ -38,7 +38,7 @@ class ContentUriImage extends ImageProvider<ContentUriImage>
|
|||
|
||||
if (bytes.lengthInBytes == 0) {
|
||||
// The file may become available later.
|
||||
PaintingBinding.instance!.imageCache!.evict(key);
|
||||
PaintingBinding.instance.imageCache.evict(key);
|
||||
throw StateError("$uri is empty and cannot be loaded as an image.");
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ class _AlbumPickerState extends State<AlbumPicker>
|
|||
_reqQuery();
|
||||
} else {
|
||||
// process the current state
|
||||
WidgetsBinding.instance!.addPostFrameCallback((_) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
setState(() {
|
||||
_onStateChange(context, _bloc.state);
|
||||
});
|
||||
|
|
|
@ -93,7 +93,7 @@ class _AlbumShareOutlierBrowserState extends State<AlbumShareOutlierBrowser> {
|
|||
_log.info("[_initBloc] Initialize bloc");
|
||||
} else {
|
||||
// process the current state
|
||||
WidgetsBinding.instance!.addPostFrameCallback((_) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
setState(() {
|
||||
_onStateChange(context, _bloc.state);
|
||||
});
|
||||
|
|
|
@ -101,7 +101,7 @@ class _ArchiveBrowserState extends State<ArchiveBrowser>
|
|||
_reqQuery();
|
||||
} else {
|
||||
// process the current state
|
||||
WidgetsBinding.instance!.addPostFrameCallback((_) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
setState(() {
|
||||
_onStateChange(context, _bloc.state);
|
||||
});
|
||||
|
|
|
@ -110,7 +110,7 @@ class _EnhancedPhotoBrowserState extends State<EnhancedPhotoBrowser>
|
|||
_reqQuery();
|
||||
} else {
|
||||
// process the current state
|
||||
WidgetsBinding.instance!.addPostFrameCallback((_) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
setState(() {
|
||||
_onStateChange(context, _bloc.state);
|
||||
});
|
||||
|
|
|
@ -104,7 +104,7 @@ class _FavoriteBrowserState extends State<FavoriteBrowser>
|
|||
_reqQuery();
|
||||
} else {
|
||||
// process the current state
|
||||
WidgetsBinding.instance!.addPostFrameCallback((_) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
setState(() {
|
||||
_onStateChange(context, _bloc.state);
|
||||
});
|
||||
|
|
|
@ -94,7 +94,7 @@ class _HomeAlbumsState extends State<HomeAlbums>
|
|||
_reqQuery();
|
||||
} else {
|
||||
// process the current state
|
||||
WidgetsBinding.instance!.addPostFrameCallback((_) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
setState(() {
|
||||
_onStateChange(context, _bloc.state);
|
||||
});
|
||||
|
|
|
@ -127,7 +127,7 @@ class _HomePhotosState extends State<HomePhotos>
|
|||
_reqQuery();
|
||||
} else {
|
||||
// process the current state
|
||||
WidgetsBinding.instance!.addPostFrameCallback((_) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
setState(() {
|
||||
_onStateChange(context, _bloc.state);
|
||||
});
|
||||
|
|
|
@ -53,7 +53,7 @@ class _LocalImageViewerState extends State<LocalImageViewer> {
|
|||
image: provider,
|
||||
fit: BoxFit.contain,
|
||||
frameBuilder: (context, child, frame, wasSynchronouslyLoaded) {
|
||||
WidgetsBinding.instance!.addPostFrameCallback((_) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_onItemLoaded();
|
||||
});
|
||||
return child;
|
||||
|
@ -126,7 +126,7 @@ class _RemoteImageViewerState extends State<RemoteImageViewer> {
|
|||
filterQuality: FilterQuality.high,
|
||||
imageRenderMethodForWeb: ImageRenderMethodForWeb.HttpGet,
|
||||
imageBuilder: (context, child, imageProvider) {
|
||||
WidgetsBinding.instance!.addPostFrameCallback((_) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_onItemLoaded();
|
||||
});
|
||||
SizeChangedLayoutNotification().dispatch(context);
|
||||
|
@ -185,7 +185,7 @@ class _ImageViewerState extends State<_ImageViewer>
|
|||
alignment: Alignment.center,
|
||||
child: NotificationListener<SizeChangedLayoutNotification>(
|
||||
onNotification: (_) {
|
||||
WidgetsBinding.instance!.addPostFrameCallback((_) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (_key.currentContext != null) {
|
||||
widget.onHeightChanged?.call(_key.currentContext!.size!.height);
|
||||
}
|
||||
|
|
|
@ -37,21 +37,21 @@ class _MeasurableItemListState extends State<MeasurableItemList>
|
|||
initState() {
|
||||
super.initState();
|
||||
|
||||
WidgetsBinding.instance!.addPostFrameCallback((_) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_prevOrientation = MediaQuery.of(context).orientation;
|
||||
WidgetsBinding.instance!.addObserver(this);
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
dispose() {
|
||||
WidgetsBinding.instance!.removeObserver(this);
|
||||
WidgetsBinding.instance.removeObserver(this);
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
didChangeMetrics() {
|
||||
WidgetsBinding.instance!.addPostFrameCallback((_) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
final orientation = MediaQuery.of(context).orientation;
|
||||
if (orientation != _prevOrientation) {
|
||||
_log.info(
|
||||
|
@ -70,8 +70,7 @@ class _MeasurableItemListState extends State<MeasurableItemList>
|
|||
_prevListWidth ??= constraints.crossAxisExtent;
|
||||
if (constraints.crossAxisExtent != _prevListWidth) {
|
||||
_log.info("[build] updateListHeight: list viewport width changed");
|
||||
WidgetsBinding.instance!
|
||||
.addPostFrameCallback((_) => updateListHeight());
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) => updateListHeight());
|
||||
_prevListWidth = constraints.crossAxisExtent;
|
||||
}
|
||||
|
||||
|
@ -80,8 +79,7 @@ class _MeasurableItemListState extends State<MeasurableItemList>
|
|||
_prevCellSize ??= cellSize;
|
||||
if (cellSize != _prevCellSize) {
|
||||
_log.info("[build] updateListHeight: cell size changed");
|
||||
WidgetsBinding.instance!
|
||||
.addPostFrameCallback((_) => updateListHeight());
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) => updateListHeight());
|
||||
_prevCellSize = cellSize;
|
||||
}
|
||||
_gridKey = _GridKey("$_uniqueToken $cellSize");
|
||||
|
|
|
@ -33,7 +33,7 @@ class _MeasureSizeRenderObject extends RenderProxyBox {
|
|||
if (newSize == null || oldSize == newSize) return;
|
||||
|
||||
oldSize = newSize;
|
||||
WidgetsBinding.instance!.addPostFrameCallback((_) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
onChange(newSize);
|
||||
});
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ class _SliverMeasureExtentRenderObject extends RenderProxySliver {
|
|||
}
|
||||
|
||||
_oldExtent = newExent;
|
||||
WidgetsBinding.instance!.addPostFrameCallback((_) => onChange(newExent));
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) => onChange(newExent));
|
||||
}
|
||||
|
||||
final void Function(double) onChange;
|
||||
|
|
|
@ -81,7 +81,7 @@ class _PeopleBrowserState extends State<PeopleBrowser> {
|
|||
_log.info("[_initBloc] Initialize bloc");
|
||||
} else {
|
||||
// process the current state
|
||||
WidgetsBinding.instance!.addPostFrameCallback((_) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
setState(() {
|
||||
_onStateChange(context, _bloc.state);
|
||||
});
|
||||
|
|
|
@ -186,7 +186,7 @@ class _RootPickerState extends State<RootPicker> {
|
|||
return;
|
||||
}
|
||||
_isInitDialogShown = true;
|
||||
SchedulerBinding.instance!.addPostFrameCallback((_) {
|
||||
SchedulerBinding.instance.addPostFrameCallback((_) {
|
||||
showDialog(
|
||||
barrierDismissible: false,
|
||||
context: context,
|
||||
|
|
|
@ -130,7 +130,7 @@ mixin SelectableItemStreamListMixin<T extends StatefulWidget> on State<T> {
|
|||
_lastSelectPosition = newLastSelectPosition;
|
||||
|
||||
_log.info("[itemStreamListItems] updateListHeight: list item changed");
|
||||
WidgetsBinding.instance!.addPostFrameCallback((_) =>
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) =>
|
||||
(_listKey.currentState as MeasurableItemListState?)
|
||||
?.updateListHeight());
|
||||
}
|
||||
|
|
|
@ -309,7 +309,7 @@ class _ShareAlbumDialogState extends State<ShareAlbumDialog> {
|
|||
|
||||
Future<void> _initBloc() async {
|
||||
if (_shareeBloc.state is ListShareeBlocSuccess) {
|
||||
WidgetsBinding.instance!.addPostFrameCallback((_) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
setState(() {
|
||||
_onShareeStateChange(context, _shareeBloc.state);
|
||||
});
|
||||
|
|
|
@ -100,7 +100,7 @@ class _SharingBrowserState extends State<SharingBrowser> {
|
|||
_log.info("[_initBloc] Initialize bloc");
|
||||
} else {
|
||||
// process the current state
|
||||
WidgetsBinding.instance!.addPostFrameCallback((_) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
setState(() {
|
||||
_onStateChange(context, _bloc.state);
|
||||
});
|
||||
|
|
|
@ -35,7 +35,7 @@ class _SplashState extends State<Splash> {
|
|||
@override
|
||||
initState() {
|
||||
super.initState();
|
||||
WidgetsBinding.instance!.addPostFrameCallback((_) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_doWork();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ class _TrashbinBrowserState extends State<TrashbinBrowser>
|
|||
_reqQuery();
|
||||
} else {
|
||||
// process the current state
|
||||
WidgetsBinding.instance!.addPostFrameCallback((_) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
setState(() {
|
||||
_onStateChange(context, _bloc.state);
|
||||
});
|
||||
|
|
|
@ -103,7 +103,7 @@ class _VideoViewerState extends State<VideoViewer>
|
|||
);
|
||||
await _controller.initialize();
|
||||
widget.onLoaded?.call();
|
||||
WidgetsBinding.instance!.addPostFrameCallback((_) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (_key.currentContext != null) {
|
||||
widget.onHeightChanged?.call(_key.currentContext!.size!.height);
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ class _VideoViewerState extends State<VideoViewer>
|
|||
|
||||
Widget _buildPlayer(BuildContext context) {
|
||||
if (_controller.value.isPlaying && !widget.canPlay) {
|
||||
WidgetsBinding.instance!.addPostFrameCallback((_) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_pause();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -475,7 +475,7 @@ class _ViewerState extends State<Viewer>
|
|||
/// Called when the page is being built after previously moved out of view
|
||||
void _onRecreatePageAfterMovedOut(BuildContext context, int index) {
|
||||
if (_isShowDetailPane && !_isClosingDetailPane) {
|
||||
WidgetsBinding.instance!.addPostFrameCallback((_) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (_pageStates[index]!.itemHeight != null) {
|
||||
setState(() {
|
||||
_openDetailPane(index);
|
||||
|
@ -483,7 +483,7 @@ class _ViewerState extends State<Viewer>
|
|||
}
|
||||
});
|
||||
} else {
|
||||
WidgetsBinding.instance!.addPostFrameCallback((_) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
_pageStates[index]!.scrollController.jumpTo(0);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue