-
Notifications
You must be signed in to change notification settings - Fork 64
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
Consistently getting Looking up a deactivated widget's ancestor is unsafe while using TextEditingController #167
Comments
Would this help? |
ijitmazumder@Abhijits-MacBook-Pro user_data_repository % flutter doctor -v wolt_modal_sheet: ^0.4.1 @ulusoyca I took a look that. Could not really wrap my head around. How to inject the text editing controller this is my decorator decorator: (child) {
|
This is the example
I have referred to. Could not really wrap my head around. As a side note I am heavily using the package and though little complex it is a wonderful package. I want to understand the root cause for this behaviour as it is not really obvious. I spent the whole day by multiple combinations but nothing worked the moment keyboard is up the dispose is getting called |
ok my last roll if dice was to copy paste
to check if I am doing anything silly but still the same. Do let me know if you want me to upload a video. Happy to help in anyway |
Hi, |
Hi just checkin in here. is anyone else facing similar problem? |
Hello @becjit import 'package:flutter/material.dart';
class SelectionScreen extends StatefulWidget {
const SelectionScreen({super.key});
@override
State<SelectionScreen> createState() => _SelectionScreenState();
}
class _SelectionScreenState extends State<SelectionScreen> {
final _nameController = TextEditingController();
@override
void dispose() {
_nameController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Pick an option'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
TextField(
decoration: InputDecoration(labelText: "Enter some text"),
controller: _nameController,
),
Padding(
padding: const EdgeInsets.all(8),
child: ElevatedButton(
onPressed: () {
// Close the screen and return "Yep!" as the result.
Navigator.pop(context, 'Yep!');
},
child: const Text('Yep!'),
),
),
Padding(
padding: const EdgeInsets.all(8),
child: ElevatedButton(
onPressed: () {
// Close the screen and return "Nope." as the result.
Navigator.pop(context, 'Nope.');
},
child: const Text('Nope.'),
),
)
],
),
),
);
}
}
Can anyone help to reproduce please ? |
Bug report
Describe the bug
Approach 1:
In a stateful page declare textediting controller and disposing it. Use the controller inside the modalsheet. Getting deactivated widget. Observation: whenever the keyboard is opening up the dispose is getting called
Approach 2: initializing the controller inside the modal sheet. Same error
Also approach 2 I am not sure where to dispose it if I want to use it in leadingBarWidget
The example mentioned #47 is not clear
Steps to reproduce
Steps to reproduce the behavior:
WoltModalSheetPage(
topBarTitle: Text(
title,
style: theme.textTheme.titleMedium,
),
Expected behavior
The dispose should not get called. Also there should be a clear example of how to use the same texteditingcontroller in leadingtopbar widget and page and the correct way to dispose it
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: