Skip to content

Commit

Permalink
fixes, upgrades
Browse files Browse the repository at this point in the history
  • Loading branch information
deckerst committed Oct 22, 2023
1 parent 0a482e6 commit 7b9213e
Show file tree
Hide file tree
Showing 50 changed files with 216 additions and 232 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -725,12 +725,19 @@ class MediaStoreImageProvider : ImageProvider() {
val df = StorageUtils.getDocumentFile(activity, oldPath, oldMediaUri)
df ?: throw Exception("failed to get document at path=$oldPath")

val requestedName = newFile.name
val renamed = df.renameTo(newFile.name)
if (!renamed) {
throw Exception("failed to rename document at path=$oldPath")
}
val effectiveName = df.name
if (requestedName != effectiveName) {
Log.w(LOG_TAG, "requested renaming document at uri=$oldMediaUri path=$oldPath with name=${requestedName} but got name=$effectiveName")
}
val newPath = File(newFile.parentFile, df.name).path

scanObsoletePath(activity, oldMediaUri, oldPath, mimeType)
return scanNewPathByMediaStore(activity, newFile.path, mimeType)
return scanNewPathByMediaStore(activity, newPath, mimeType)
}

private suspend fun renameSingleByFile(
Expand Down
36 changes: 18 additions & 18 deletions lib/geo/topojson.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ class Topology extends TopologyJsonObject {
final List<List<List<num>>> arcs;
final Transform? transform;

Topology.parse(Map<String, dynamic> data)
Topology.parse(super.data)
: objects = Map.fromEntries((data['objects'] as Map).cast<String, dynamic>().entries.map((kv) {
final name = kv.key;
final geometry = Geometry.build(kv.value);
return geometry != null ? MapEntry(name, geometry) : null;
}).whereNotNull()),
arcs = (data['arcs'] as List).cast<List>().map((arc) => arc.cast<List>().map((position) => position.cast<num>()).toList()).toList(),
transform = data.containsKey('transform') ? Transform.parse((data['transform'] as Map).cast<String, dynamic>()) : null,
super.parse(data);
super.parse();

List<List<num>> _arcAt(int index) {
var arc = arcs[index < 0 ? ~index : index];
Expand Down Expand Up @@ -131,10 +131,10 @@ abstract class Geometry extends TopologyJsonObject {
final dynamic id;
final Map<String, dynamic>? properties;

Geometry.parse(Map<String, dynamic> data)
Geometry.parse(super.data)
: id = data.containsKey('id') ? data['id'] : null,
properties = data.containsKey('properties') ? data['properties'] as Map<String, dynamic>? : null,
super.parse(data);
super.parse();

static Geometry? build(Map<String, dynamic> data) {
final type = _parseTopoJsonObjectType(data['type'] as String?);
Expand Down Expand Up @@ -165,41 +165,41 @@ abstract class Geometry extends TopologyJsonObject {
class Point extends Geometry {
final List<num> coordinates;

Point.parse(Map<String, dynamic> data)
Point.parse(super.data)
: coordinates = (data['coordinates'] as List).cast<num>(),
super.parse(data);
super.parse();
}

class MultiPoint extends Geometry {
final List<List<num>> coordinates;

MultiPoint.parse(Map<String, dynamic> data)
MultiPoint.parse(super.data)
: coordinates = (data['coordinates'] as List).cast<List>().map((position) => position.cast<num>()).toList(),
super.parse(data);
super.parse();
}

class LineString extends Geometry {
final List<int> arcs;

LineString.parse(Map<String, dynamic> data)
LineString.parse(super.data)
: arcs = (data['arcs'] as List).cast<int>(),
super.parse(data);
super.parse();
}

class MultiLineString extends Geometry {
final List<List<int>> arcs;

MultiLineString.parse(Map<String, dynamic> data)
MultiLineString.parse(super.data)
: arcs = (data['arcs'] as List).cast<List>().map((arc) => arc.cast<int>()).toList(),
super.parse(data);
super.parse();
}

class Polygon extends Geometry {
final List<List<int>> arcs;

Polygon.parse(Map<String, dynamic> data)
Polygon.parse(super.data)
: arcs = (data['arcs'] as List).cast<List>().map((arc) => arc.cast<int>()).toList(),
super.parse(data);
super.parse();

List<List<List<num>>>? _rings;

Expand All @@ -217,9 +217,9 @@ class Polygon extends Geometry {
class MultiPolygon extends Geometry {
final List<List<List<int>>> arcs;

MultiPolygon.parse(Map<String, dynamic> data)
MultiPolygon.parse(super.data)
: arcs = (data['arcs'] as List).cast<List>().map((polygon) => polygon.cast<List>().map((arc) => arc.cast<int>()).toList()).toList(),
super.parse(data);
super.parse();

List<List<List<List<num>>>>? _polygons;

Expand All @@ -237,9 +237,9 @@ class MultiPolygon extends Geometry {
class GeometryCollection extends Geometry {
final List<Geometry> geometries;

GeometryCollection.parse(Map<String, dynamic> data)
GeometryCollection.parse(super.data)
: geometries = (data['geometries'] as List).cast<Map<String, dynamic>>().map(Geometry.build).whereNotNull().toList(),
super.parse(data);
super.parse();

@override
bool containsPoint(Topology topology, List<num> point) {
Expand Down
4 changes: 2 additions & 2 deletions lib/model/events.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ class ActionEvent<T> extends Equatable {

@immutable
class ActionStartedEvent<T> extends ActionEvent<T> {
const ActionStartedEvent(T action) : super(action);
const ActionStartedEvent(super.action);
}

@immutable
class ActionEndedEvent<T> extends ActionEvent<T> {
const ActionEndedEvent(T action) : super(action);
const ActionEndedEvent(super.action);
}
2 changes: 1 addition & 1 deletion lib/widgets/about/about_tv_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class AboutTvPage extends StatelessWidget {
}

class _Content extends StatefulWidget {
const _Content({Key? key}) : super(key: key);
const _Content();

@override
State<_Content> createState() => _ContentState();
Expand Down
8 changes: 2 additions & 6 deletions lib/widgets/about/tv_license_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,7 @@ class _PackageLicensePageState extends State<_PackageLicensePage> {
return true;
}());
for (final LicenseEntry license in widget.licenseEntries) {
if (!mounted) {
return;
}
if (!mounted) return;
assert(() {
Timeline.timeSync('_initLicenses()', () {}, flow: Flow.step(debugFlowId));
return true;
Expand All @@ -231,9 +229,7 @@ class _PackageLicensePageState extends State<_PackageLicensePage> {
Priority.animation,
debugLabel: 'License',
);
if (!mounted) {
return;
}
if (!mounted) return;
setState(() {
_licenses.add(const Padding(
padding: EdgeInsets.all(18.0),
Expand Down
2 changes: 1 addition & 1 deletion lib/widgets/common/basic/insets.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class BottomPaddingSliver extends StatelessWidget {
}

class TvTileGridBottomPaddingSliver extends StatelessWidget {
const TvTileGridBottomPaddingSliver({Key? key}) : super(key: key);
const TvTileGridBottomPaddingSliver({super.key});

@override
Widget build(BuildContext context) {
Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/common/basic/labeled_checkbox.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ class LabeledCheckbox extends StatefulWidget {
final String text;

const LabeledCheckbox({
Key? key,
super.key,
required this.value,
required this.onChanged,
required this.text,
}) : super(key: key);
});

@override
State<LabeledCheckbox> createState() => _LabeledCheckboxState();
Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/common/behaviour/known_extent_scroll_physics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ class KnownExtentScrollPhysics extends ScrollPhysics {
const KnownExtentScrollPhysics({
required this.indexToScrollOffset,
required this.scrollOffsetToIndex,
ScrollPhysics? parent,
}) : super(parent: parent);
super.parent,
});

@override
KnownExtentScrollPhysics applyTo(ScrollPhysics? ancestor) {
Expand Down
9 changes: 4 additions & 5 deletions lib/widgets/common/behaviour/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ class DirectPageTransitionsTheme extends PageTransitionsTheme {

class DirectMaterialPageRoute<T> extends PageRouteBuilder<T> {
DirectMaterialPageRoute({
RouteSettings? settings,
super.settings,
required WidgetBuilder builder,
}) : super(
settings: settings,
transitionDuration: Duration.zero,
pageBuilder: (context, a, sa) => builder(context),
);
Expand All @@ -32,9 +31,9 @@ class DirectMaterialPageRoute<T> extends PageRouteBuilder<T> {

class TransparentMaterialPageRoute<T> extends PageRouteBuilder<T> {
TransparentMaterialPageRoute({
RouteSettings? settings,
required RoutePageBuilder pageBuilder,
}) : super(settings: settings, pageBuilder: pageBuilder);
super.settings,
required super.pageBuilder,
});

@override
bool get opaque => false;
Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/common/behaviour/sloppy_scroll_physics.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class SloppyScrollPhysics extends ScrollPhysics {
const SloppyScrollPhysics({
required this.gestureSettings,
this.touchSlopFactor = 1,
ScrollPhysics? parent,
}) : super(parent: parent);
super.parent,
});

@override
SloppyScrollPhysics applyTo(ScrollPhysics? ancestor) {
Expand Down
12 changes: 5 additions & 7 deletions lib/widgets/common/fx/sweeper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,12 @@ class _SweeperState extends State<Sweeper> with SingleTickerProviderStateMixin {
setState(() {});
await Future.delayed(ADurations.sweeperOpacityAnimation * timeDilation);
_isAppearing = false;
if (mounted) {
_angleAnimationController.reset();
unawaited(_angleAnimationController.forward());
}
}
if (mounted) {
setState(() {});
if (!mounted) return;
_angleAnimationController.reset();
unawaited(_angleAnimationController.forward());
}
if (!mounted) return;
setState(() {});
}
}

Expand Down
8 changes: 3 additions & 5 deletions lib/widgets/common/grid/item_tracker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,9 @@ class _GridItemTrackerState<T> extends State<GridItemTracker<T>> with WidgetsBin
// so that we can handle window orientation change with the previous metrics,
// regardless of the `View`/`WidgetsBindingObserver` order uncertainty
await Future.delayed(const Duration(milliseconds: 500));

if (mounted) {
_lastSectionedListLayout = context.read<SectionedListLayout<T>>();
_lastScrollableSize = scrollableSize;
}
if (!mounted) return;
_lastSectionedListLayout = context.read<SectionedListLayout<T>>();
_lastScrollableSize = scrollableSize;
}

void _onLayoutChanged() {
Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/common/grid/sections/fixed/row.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class FixedExtentGridRow extends MultiChildRenderObjectWidget {
required this.height,
required this.spacing,
required this.textDirection,
required List<Widget> children,
}) : super(children: children);
required super.children,
});

@override
RenderObject createRenderObject(BuildContext context) {
Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/common/grid/sections/mosaic/row.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class MosaicGridRow extends MultiChildRenderObjectWidget {
required this.rowLayout,
required this.spacing,
required this.textDirection,
required List<Widget> children,
}) : super(children: children);
required super.children,
});

@override
RenderObject createRenderObject(BuildContext context) {
Expand Down
9 changes: 4 additions & 5 deletions lib/widgets/common/grid/sliver.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ class _SliverKnownExtentList extends SliverMultiBoxAdaptorWidget {
final List<SectionLayout> sectionLayouts;

const _SliverKnownExtentList({
required SliverChildDelegate delegate,
required super.delegate,
required this.sectionLayouts,
}) : super(delegate: delegate);
});

@override
_RenderSliverKnownExtentBoxAdaptor createRenderObject(BuildContext context) {
Expand All @@ -69,10 +69,9 @@ class _RenderSliverKnownExtentBoxAdaptor extends RenderSliverMultiBoxAdaptor {
}

_RenderSliverKnownExtentBoxAdaptor({
required RenderSliverBoxChildManager childManager,
required super.childManager,
required List<SectionLayout> sectionLayouts,
}) : _sectionLayouts = sectionLayouts,
super(childManager: childManager);
}) : _sectionLayouts = sectionLayouts;

SectionLayout? sectionAtIndex(int index) => sectionLayouts.firstWhereOrNull((section) => section.hasChild(index));

Expand Down
9 changes: 3 additions & 6 deletions lib/widgets/common/map/leaflet/latlng_tween.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@ import 'package:latlong2/latlong.dart';

class LatLngTween extends Tween<LatLng?> {
LatLngTween({
required LatLng? begin,
required LatLng? end,
}) : super(
begin: begin,
end: end,
);
required super.begin,
required super.end,
});

@override
LatLng? lerp(double t) => LatLngUtils.lerp(begin, end, t);
Expand Down
7 changes: 3 additions & 4 deletions lib/widgets/common/search/page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,9 @@ class _SearchPageState extends State<SearchPage> {

void _onQueryChanged() {
_debouncer(() {
if (mounted) {
// rebuild ourselves because query changed.
setState(() {});
}
if (!mounted) return;
// rebuild ourselves because query changed.
setState(() {});
});
}

Expand Down
5 changes: 2 additions & 3 deletions lib/widgets/common/thumbnail/image.dart
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,8 @@ class _ThumbnailImageState extends State<ThumbnailImage> {
}

void _onError(Object exception, StackTrace? stackTrace) {
if (mounted) {
setState(() => _lastException = exception);
}
if (!mounted) return;
setState(() => _lastException = exception);
}

bool _needSizedProvider(ImageInfo? currentImageInfo) {
Expand Down
3 changes: 2 additions & 1 deletion lib/widgets/dialogs/pick_dialogs/location_pick_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,8 @@ class _AddressRowState extends State<_AddressRow> {
Future<void> _updateAddress() async {
final location = widget.location;
final addressLine = await _getAddressLine(location);
if (mounted && location == widget.location) {
if (!mounted) return;
if (location == widget.location) {
_addressLineNotifier.value = addressLine;
}
}
Expand Down
Loading

0 comments on commit 7b9213e

Please sign in to comment.