Unverified Commit 1f0730e6 authored by Polina Cherkasova's avatar Polina Cherkasova Committed by GitHub

DraggableScrollableActuator should dispose notifier. (#133917)

parent 41ebf282
...@@ -1015,12 +1015,12 @@ class _DraggableScrollableSheetScrollPosition extends ScrollPositionWithSingleCo ...@@ -1015,12 +1015,12 @@ class _DraggableScrollableSheetScrollPosition extends ScrollPositionWithSingleCo
/// in library users' code). Generally, it's easier to control the sheet /// in library users' code). Generally, it's easier to control the sheet
/// directly by creating a controller and passing the controller to the sheet in /// directly by creating a controller and passing the controller to the sheet in
/// its constructor (see [DraggableScrollableSheet.controller]). /// its constructor (see [DraggableScrollableSheet.controller]).
class DraggableScrollableActuator extends StatelessWidget { class DraggableScrollableActuator extends StatefulWidget {
/// Creates a widget that can notify descendent [DraggableScrollableSheet]s /// Creates a widget that can notify descendent [DraggableScrollableSheet]s
/// to reset to their initial position. /// to reset to their initial position.
/// ///
/// The [child] parameter is required. /// The [child] parameter is required.
DraggableScrollableActuator({ const DraggableScrollableActuator({
super.key, super.key,
required this.child, required this.child,
}); });
...@@ -1031,7 +1031,6 @@ class DraggableScrollableActuator extends StatelessWidget { ...@@ -1031,7 +1031,6 @@ class DraggableScrollableActuator extends StatelessWidget {
/// Must not be null. /// Must not be null.
final Widget child; final Widget child;
final _ResetNotifier _notifier = _ResetNotifier();
/// Notifies any descendant [DraggableScrollableSheet] that it should reset /// Notifies any descendant [DraggableScrollableSheet] that it should reset
/// to its initial position. /// to its initial position.
...@@ -1047,9 +1046,22 @@ class DraggableScrollableActuator extends StatelessWidget { ...@@ -1047,9 +1046,22 @@ class DraggableScrollableActuator extends StatelessWidget {
return notifier._sendReset(); return notifier._sendReset();
} }
@override
State<DraggableScrollableActuator> createState() => _DraggableScrollableActuatorState();
}
class _DraggableScrollableActuatorState extends State<DraggableScrollableActuator> {
final _ResetNotifier _notifier = _ResetNotifier();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return _InheritedResetNotifier(notifier: _notifier, child: child); return _InheritedResetNotifier(notifier: _notifier, child: widget.child);
}
@override
void dispose() {
_notifier.dispose();
super.dispose();
} }
} }
......
...@@ -415,7 +415,7 @@ void main() { ...@@ -415,7 +415,7 @@ void main() {
expect(tester.getCenter(find.byType(FloatingActionButton)), const Offset(_leftOffsetX, _floatOffsetY)); expect(tester.getCenter(find.byType(FloatingActionButton)), const Offset(_leftOffsetX, _floatOffsetY));
}); });
testWidgets('centerFloat', (WidgetTester tester) async { testWidgetsWithLeakTracking('centerFloat', (WidgetTester tester) async {
await tester.pumpWidget(_singleFabScaffold(FloatingActionButtonLocation.centerFloat)); await tester.pumpWidget(_singleFabScaffold(FloatingActionButtonLocation.centerFloat));
expect(tester.getCenter(find.byType(FloatingActionButton)), const Offset(_centerOffsetX, _floatOffsetY)); expect(tester.getCenter(find.byType(FloatingActionButton)), const Offset(_centerOffsetX, _floatOffsetY));
...@@ -1037,7 +1037,7 @@ void main() { ...@@ -1037,7 +1037,7 @@ void main() {
); );
}); });
testWidgets('centerFloat', (WidgetTester tester) async { testWidgetsWithLeakTracking('centerFloat', (WidgetTester tester) async {
const Rect defaultRect = Rect.fromLTRB(372.0, 478.0, 428.0, 534.0); const Rect defaultRect = Rect.fromLTRB(372.0, 478.0, 428.0, 534.0);
// Positioned relative to BottomNavigationBar // Positioned relative to BottomNavigationBar
const Rect bottomNavigationBarRect = Rect.fromLTRB(372.0, 422.0, 428.0, 478.0); const Rect bottomNavigationBarRect = Rect.fromLTRB(372.0, 422.0, 428.0, 478.0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment