Description
Internal: b/153942448
Steps to Reproduce
If we have a CompositedTransformFollower
that follows a CompositedTransformTarget
, and we scroll the target out of the screen, the layer link between them gets broken. This results in the follower showing at the top left of the screen.
We can hide the follower by setting showWhenUnlinked
to false, but it still responds to taps of the user.
To reproduce this, I created this small app:
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage();
@override
_MyHomePageState createState() => new _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
LayerLink _layerLink = LayerLink();
FocusNode _focusNode = FocusNode();
@override
void initState() {
super.initState();
_focusNode.addListener(() {
if (_focusNode.hasFocus) {
Overlay.of(context).insert(OverlayEntry(
builder: (context) =>
Positioned(
width: 200.0,
child: CompositedTransformFollower(
link: this._layerLink,
child: Material(
elevation: 4.0,
child: RaisedButton(
onPressed: () {
print('I was pressed');
}
),
),
),
)
));
}
});
}
@override
Widget build(BuildContext context) {
return new Scaffold(
body: ListView(
padding: EdgeInsets.all(20.0),
children: <Widget>[
SizedBox(height: 200.0,),
CompositedTransformTarget(
link: this._layerLink,
child: TextField(
focusNode: this._focusNode,
),
),
SizedBox(height: 700.0,)
],
)
);
}
}
If you focus the TextField
, the button shows, then if you scroll the TextField
out of the screen, you can see the button stays at the top left of the screen. If you tap the button, it prints to the console "I was pressed".
Now, set the showWhenUnlinked
to false and repeat the procedure. Even though the button won't be showing anymore, it will still respond to taps.
Logs
[✓] Flutter (Channel beta, v0.6.0, on Linux, locale en_US.UTF-8)
• Flutter version 0.6.0 at /home/aalhamali/flutter
• Framework revision 9299c02cf7 (2 weeks ago), 2018-08-16 00:35:12 +0200
• Engine revision e3687f70c7
• Dart version 2.1.0-dev.0.0.flutter-be6309690f
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.1)
• Android SDK at /home/aalhamali/Android/Sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.1
• Java binary at: /opt/android-studio/jre/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
• All Android licenses accepted.
[✓] Android Studio (version 3.1)
• Android Studio at /opt/android-studio
• Flutter plugin version 26.0.1
• Dart plugin version 173.4700
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1024-b01)
[✓] Connected devices (1 available)
• Android SDK built for x86 64 • emulator-5554 • android-x64 • Android 9 (API 28) (emulator)
• No issues found!
Activity
shakil807g commentedon Sep 2, 2018
how about manually hiding CompositedTransformFollower when showWhenUnlinked is false ??
AbdulRahmanAlHamali commentedon Sep 2, 2018
You mean when the follower is unlinked from the target? Is there an efficient way to listen to that?
BondarenkoStas commentedon Oct 24, 2019
did you find a solution? does the issue still exist with current flutter stable?
jkmpariab commentedon Nov 1, 2019
yes, the issue is still there
my 'flutter doctor -v'
sh0umik commentedon Jan 20, 2020
this issue still exits . Found this bug while exploring flutter_typeahead package
lock commentedon May 5, 2020
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -v
and a minimal reproduction of the issue.1 remaining item