Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compile error introduced by #44 #47

Merged
merged 6 commits into from
Mar 7, 2022
Merged
Changes from 1 commit
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
Next Next commit
copy Flutter sources about LayerLink and its friends
  • Loading branch information
fzyzcjy committed Mar 7, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 558663f50377125d5edefea99fe82282a52f0106
21 changes: 11 additions & 10 deletions lib/src/custom_follower.dart
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ import 'package:flutter/widgets.dart';
import 'package:vector_math/vector_math_64.dart';

import 'anchor.dart';
import 'flutter_src/layer.dart';
import 'portal.dart';

/// @nodoc
@@ -24,7 +25,7 @@ class CustomCompositedTransformFollower extends SingleChildRenderObjectWidget {
final Anchor anchor;

/// @nodoc
final LayerLink link;
final MyLayerLink link;

/// @nodoc
final OverlayLink overlayLink;
@@ -58,7 +59,7 @@ class CustomCompositedTransformFollower extends SingleChildRenderObjectWidget {
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(DiagnosticsProperty<Anchor>('anchor', anchor));
properties.add(DiagnosticsProperty<LayerLink>('link', link));
properties.add(DiagnosticsProperty<MyLayerLink>('link', link));
properties
.add(DiagnosticsProperty<OverlayLink>('overlayLink', overlayLink));
properties.add(DiagnosticsProperty<Size>('targetSize', targetSize));
@@ -70,7 +71,7 @@ class CustomCompositedTransformFollower extends SingleChildRenderObjectWidget {
class CustomRenderFollowerLayer extends RenderProxyBox {
/// @nodoc
CustomRenderFollowerLayer({
required LayerLink link,
required MyLayerLink link,
required OverlayLink overlayLink,
required Size targetSize,
required Anchor anchor,
@@ -93,12 +94,12 @@ class CustomRenderFollowerLayer extends RenderProxyBox {
}
}

LayerLink _link;
MyLayerLink _link;

/// @nodoc
LayerLink get link => _link;
MyLayerLink get link => _link;

set link(LayerLink value) {
set link(MyLayerLink value) {
if (_link == value) {
return;
}
@@ -170,7 +171,7 @@ class CustomRenderFollowerLayer extends RenderProxyBox {
/// [PortalTarget].
///
/// The reason we cannot simply access the [link]'s leader in [paint] is that
/// the leader is only attached to the [LayerLink] in [LeaderLayer.attach],
/// the leader is only attached to the [MyLayerLink] in [LeaderLayer.attach],
/// which is called in the compositing phase which is after the paint phase.
Offset _computeLinkedOffset(Offset leaderOffset) {
assert(
@@ -234,7 +235,7 @@ class CustomRenderFollowerLayer extends RenderProxyBox {
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(DiagnosticsProperty<LayerLink>('link', link));
properties.add(DiagnosticsProperty<MyLayerLink>('link', link));
properties
.add(DiagnosticsProperty<OverlayLink>('overlayLink', overlayLink));
properties.add(
@@ -266,7 +267,7 @@ class _CustomFollowerLayer extends ContainerLayer {
required this.linkedOffsetCallback,
});

LayerLink link;
MyLayerLink link;

/// Callback that is called to compute the linked offset of the follower layer
/// based on the `leaderOffset` of the leader layer.
@@ -457,7 +458,7 @@ class _CustomFollowerLayer extends ContainerLayer {
@override
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
super.debugFillProperties(properties);
properties.add(DiagnosticsProperty<LayerLink>('link', link));
properties.add(DiagnosticsProperty<MyLayerLink>('link', link));
properties.add(
TransformProperty('transform', getLastTransform(), defaultValue: null));
properties.add(DiagnosticsProperty<Offset Function(Offset leaderOffset)>(
57 changes: 57 additions & 0 deletions lib/src/flutter_src/basic.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// ignore_for_file: unnecessary_null_comparison, diagnostic_describe_all_properties

import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'layer.dart';
import 'proxy_box.dart';

/// A widget that can be targeted by a [CompositedTransformFollower].
///
/// When this widget is composited during the compositing phase (which comes
/// after the paint phase, as described in [WidgetsBinding.drawFrame]), it
/// updates the [link] object so that any [CompositedTransformFollower] widgets
/// that are subsequently composited in the same frame and were given the same
/// [LayerLink] can position themselves at the same screen location.
///
/// A single [MyCompositedTransformTarget] can be followed by multiple
/// [CompositedTransformFollower] widgets.
///
/// The [MyCompositedTransformTarget] must come earlier in the paint order than
/// any linked [CompositedTransformFollower]s.
///
/// See also:
///
/// * [CompositedTransformFollower], the widget that can target this one.
/// * [LeaderLayer], the layer that implements this widget's logic.
class MyCompositedTransformTarget extends SingleChildRenderObjectWidget {
/// Creates a composited transform target widget.
///
/// The [link] property must not be null, and must not be currently being used
/// by any other [MyCompositedTransformTarget] object that is in the tree.
const MyCompositedTransformTarget({
Key? key,
required this.link,
Widget? child,
}) : assert(link != null),
super(key: key, child: child);

/// The link object that connects this [MyCompositedTransformTarget] with one or
/// more [CompositedTransformFollower]s.
///
/// This property must not be null. The object must not be associated with
/// another [MyCompositedTransformTarget] that is also being painted.
final MyLayerLink link;

@override
MyRenderLeaderLayer createRenderObject(BuildContext context) {
return MyRenderLeaderLayer(
link: link,
);
}

@override
void updateRenderObject(BuildContext context, MyRenderLeaderLayer renderObject) {
renderObject.link = link;
}
}

Loading