Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>8.0</string>
<string>9.0</string>
</dict>
</plist>
10 changes: 5 additions & 5 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 46;
objectVersion = 50;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -135,7 +135,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1020;
LastUpgradeCheck = 1300;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
Expand Down Expand Up @@ -280,7 +280,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down Expand Up @@ -362,7 +362,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -411,7 +411,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1020"
LastUpgradeVersion = "1300"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
31 changes: 15 additions & 16 deletions example/lib/main_example_readme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ void main() {
runApp(const _LocalHeroApp());
}

class _Box extends StatelessWidget {
const _Box({
Key? key,
}) : super(key: key);

@override
Widget build(BuildContext context) {
return Container(
color: Colors.red,
width: 50,
height: 50,
);
}
}

class _LocalHeroApp extends StatelessWidget {
const _LocalHeroApp({
Key? key,
Expand All @@ -28,7 +43,6 @@ class _LocalHeroPage extends StatelessWidget {
return const Scaffold(
body: SafeArea(
child: LocalHeroScope(
duration: Duration(milliseconds: 300),
curve: Curves.easeInOut,
child: _LocalHeroPlayground(),
),
Expand Down Expand Up @@ -79,18 +93,3 @@ class _LocalHeroPlaygroundState extends State<_LocalHeroPlayground> {
);
}
}

class _Box extends StatelessWidget {
const _Box({
Key? key,
}) : super(key: key);

@override
Widget build(BuildContext context) {
return Container(
color: Colors.red,
width: 50,
height: 50,
);
}
}
3 changes: 1 addition & 2 deletions lib/src/rendering/controller.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:flutter/animation.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/scheduler.dart';

Expand All @@ -16,7 +15,7 @@ class LocalHeroController {
required this.curve,
required this.createRectTween,
required this.tag,
}) : link = LayerLink(),
}) : link = LayerLink(),
_vsync = vsync,
_initialDuration = duration;

Expand Down
25 changes: 15 additions & 10 deletions lib/src/rendering/layer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ class LocalHeroLayer extends ContainerLayer {

Offset? _transformOffset<S>(Offset localPosition) {
if (_inverseDirty) {
_invertedTransform = Matrix4.tryInvert(getLastTransform()!);
_inverseDirty = false;
final lastTransform = getLastTransform();
if (lastTransform != null) {
_invertedTransform = Matrix4.tryInvert(lastTransform);
_inverseDirty = false;
}
}
if (_invertedTransform == null) {
return null;
Expand All @@ -51,7 +54,7 @@ class LocalHeroLayer extends ContainerLayer {
Offset localPosition, {
required bool onlyFirst,
}) {
if (controller.link.leader == null) {
if (!controller.link.leaderConnected) {
return false;
}
final Offset? transformedOffset = _transformOffset<S>(localPosition);
Expand Down Expand Up @@ -90,7 +93,9 @@ class LocalHeroLayer extends ContainerLayer {
// Apply each layer to the matrix in turn, starting from the last layer,
// and providing the previous layer as the child.
for (int index = layers.length - 1; index > 0; index -= 1) {
layers[index]!.applyTransform(layers[index - 1], result);
if (layers[index - 1] != null) {
layers[index]!.applyTransform(layers[index - 1], result);
}
}
return result;
}
Expand All @@ -99,12 +104,13 @@ class LocalHeroLayer extends ContainerLayer {
void _establishTransform() {
_lastTransform = null;
// Check to see if we are linked.
if (controller.link.leader == null) {
if (!controller.link.leaderConnected) {
return;
}
// If we're linked, check the link is valid.
assert(controller.link.leader!.owner == owner,
'Linked LeaderLayer anchor is not in the same layer tree as the FollowerLayer.');
if (controller.link.debugLeader?.owner != owner) {
return;
}
// Collect all our ancestors into a Set so we can recognize them.
final Set<Layer> ancestors = <Layer>{};
Layer? ancestor = parent;
Expand All @@ -114,7 +120,7 @@ class LocalHeroLayer extends ContainerLayer {
}
// Collect all the layers from a hypothetical child (null) of the target
// layer up to the common ancestor layer.
ContainerLayer layer = controller.link.leader!;
ContainerLayer layer = controller.link.debugLeader!;
final List<ContainerLayer?> forwardLayers = <ContainerLayer?>[null, layer];
do {
layer = layer.parent!;
Expand Down Expand Up @@ -162,7 +168,7 @@ class LocalHeroLayer extends ContainerLayer {

@override
void addToScene(ui.SceneBuilder builder, [Offset layerOffset = Offset.zero]) {
if (controller.link.leader == null) {
if (!controller.link.leaderConnected) {
_lastTransform = null;
_lastOffset = null;
_inverseDirty = true;
Expand All @@ -187,7 +193,6 @@ class LocalHeroLayer extends ContainerLayer {
@override
void applyTransform(Layer? child, Matrix4 transform) {
assert(child != null);
assert(transform != null);

transform.multiply(_lastTransform!);
}
Expand Down
1 change: 0 additions & 1 deletion lib/src/rendering/local_hero_layer.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:flutter/animation.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/rendering.dart';
import 'package:local_hero/src/rendering/controller.dart';
import 'package:local_hero/src/rendering/layer.dart';
Expand Down
12 changes: 6 additions & 6 deletions lib/src/widgets/local_hero.dart
Original file line number Diff line number Diff line change
Expand Up @@ -59,27 +59,27 @@ class LocalHero extends StatefulWidget {

class _LocalHeroState extends State<LocalHero>
with SingleTickerProviderStateMixin<LocalHero> {
late LocalHeroController controller;
late LocalHeroScopeState scopeState;
late LocalHeroController? controller;
late LocalHeroScopeState? scopeState;

@override
void initState() {
super.initState();
scopeState = context.getLocalHeroScopeState();
controller = scopeState.track(context, widget);
scopeState = widget.enabled ? context.getLocalHeroScopeState() : null;
controller = scopeState?.track(context, widget);
}

@override
void dispose() {
scopeState.untrack(widget);
scopeState?.untrack(widget);
super.dispose();
}

@override
Widget build(BuildContext context) {
return widget.enabled
? LocalHeroLeader(
controller: controller,
controller: controller!,
child: widget.child,
)
: widget.child;
Expand Down
1 change: 0 additions & 1 deletion lib/src/widgets/local_hero_scope.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter/widgets.dart';
import 'package:local_hero/src/rendering/controller.dart';
import 'package:local_hero/src/widgets/local_hero.dart';
import 'package:local_hero/src/widgets/local_hero_layer.dart';
Expand Down