Hi everyone!
I would appreciate your thoughts on this. I am trying to determine if the following behavior is a problem in my code or a potential bug in Flutter.
When a ValueListenableBuilder rebuilds, it terminates the current scroll touch event.
Below is a code example and a link to a video demonstrating the issue.
import 'package:flutter/material.dart';
import 'dart:async';
class MainApp extends StatefulWidget {
const MainApp({super.key});
@override
State<MainApp> createState() => _MainAppState();
}
class _MainAppState extends State<MainApp> {
final titleValue = ValueNotifier<String>('0');
int counter = 0;
@override
void initState() {
super.initState();
Timer.periodic(const Duration(milliseconds: 1500), (timer) {
counter++;
titleValue.value = counter.toString();
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: SingleChildScrollView(
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight: MediaQuery.sizeOf(context).height * 1.2,
),
child: Column(
children: [
const SizedBox(height: 300),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
const Text('Time: ', style: TextStyle(color: Colors.red)),
ValueListenableBuilder(
valueListenable: titleValue,
builder: (context, value, child) {
return Text(
value,
style: const TextStyle(
color: Colors.blue,
fontFeatures: [FontFeature.tabularFigures()],
),
);
},
),
],
),
Container(width: 200, height: 200, color: Colors.blue),
],
),
),
),
),
);
}
}
void main() {
runApp(const MainApp());
}
In the following video, scrolling is not ended by the user, but when the ValueNotifier fires, it cancels the touch event.