-
Notifications
You must be signed in to change notification settings - Fork 28.5k
_debugUltimatePreviousSiblingOf(after, equals: _firstChild) is not true. #11895
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
Comments
Yikes, that's not a good sign. |
Also encountered this today. Seemed to be linked to putting focus on a node that was currently offscreen. This main.dart file should reproduce it: import 'package:flutter/material.dart';
void main() {
runApp(new Test11895Body());
}
class Test11895Body extends StatefulWidget{
Test11895BodyState createState() => new Test11895BodyState();
}
class Test11895BodyState extends State<Test11895Body>{
List<String> model = ['Focus on this textfield', 'Keep focused on the first textfield', 'Scroll down and continue adding more cards with the button below'];
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new Scaffold(
appBar: new AppBar(
title: new Text('Bug #11895'),
),
body: new ListView(
primary:true,
children: buildNoteCards(),
),
),
);
}
List<Widget> buildNoteCards(){
List<Widget> notes = new List<Widget>();
for (int i = 0; i < model.length; i++){
notes.add(new Card(
child: new Container(
constraints: new BoxConstraints(minHeight: 150.0),
child: new TextField(
controller: new TextEditingController(text: model[i]),
maxLines: 5,
),
),
)
);
}
notes.add(
new GestureDetector(
onTap: _generateNewNote,
child: new Container(
child: new Card(
child: new Icon(Icons.note_add, size:30.0),
),
),
),
);
return notes;
}
void _generateNewNote(){
setState((){
model.add('Keep going... note # ${model.length + 1}');
});
}
} |
See also https://gist.github.com/rmarau/baa31a9c4032de388a2b7777c8bae27e for another repro. |
I'm marking it customer critical because so many people are hitting it. |
Anyone figure this out? I'm experiencing it with the tab bar, textfield, and listview.... |
I also ran into problems using AutomaticKeepAliveClientMixin with more than two tabs. In the end we replaced it by lifting our state higher in the widget hierarchy. You can read more about it here. Hope it helps... |
Any solution? |
@mralexsaavedra is the error only occuring when the keyboard is opened / a textfield is focused? |
@jonasbark In my case the problem is the following: |
I'm seeing this when using AutomaticKeepAliveClientMixin with several tabs. If I tap on neighbour tabs — the tabs immediately to the left or right of the one currently selected — then it doesn't crash. But if I go to a non-neighbour, say tab 1 to tab 3, then it reliably crashes. |
@SteveAlexander I see the exact same problem, I had created a separate issue for it (#18350) but it looks like it's the same problem. |
Here's a minimal example that reproduces the crash for me: To reproduce, run the app, tap the "baz" tab, then tap back to "foo". |
cc @HansMuller since this occurs with tabs in particular |
Root cause of remaining issue is that RenderSliverList is losing track of leading children that are or come before a kept alive child. Have a more focused repro, working on the fix. |
I read a thread and can't find a solution. Does it exist for this issue? import 'package:flutter/material.dart';
void main() => runApp(new TabBarDemo());
class TabBarDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: DefaultTabController(
length: 4,
child: Scaffold(
appBar: AppBar(
bottom: TabBar(
tabs: [
Tab(text: "1"),
Tab(text: "2"),
Tab(text: "3"),
Tab(text: "4"),
],
),
title: Text('Select last tab'),
),
body: TabBarView(
children: [
TabContent(),
TabContent(),
TabContent(),
TabContent(),
],
),
),
),
);
}
}
class TabContent extends StatefulWidget {
@override
_TabContentState createState() => _TabContentState();
}
class _TabContentState extends State<TabContent>
with AutomaticKeepAliveClientMixin<TabContent>
{
@override
bool get wantKeepAlive => true;
@override
Widget build(BuildContext context) {
return Container();
}
} error stacktrace here https://pastebin.com/gAU5gyYn flutter version
|
previous code example is simplified, so if you wonder, why I use stateful widget for a Container only, here is a code example that uses stateful capabilities: |
@nailgilaziev - the PR I linked to this seems to resolve the issue, althrough I'm still seeing an exception get thrown.. Will look into it. |
import 'package:flutter/material.dart';
import './deal/deal.dart';
import './home/home.dart';
import './mine/mine.dart';
import './stockrights/stockrights.dart';
void main() => runApp(new App());
class App extends StatefulWidget {
@override
createState() => new AppState();
}
class AppState extends State<App> {
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new Scaffold(
backgroundColor: Colors.white,
body: new SafeArea(
child: new MainTabWidget(),
bottom: true,
),
),
theme: new ThemeData(primaryColor: Colors.black, accentColor: Colors.lightBlue, primaryColorBrightness: Brightness.light, hintColor: Color(0xffdddddd), highlightColor: Color(0xffeeeeee), inputDecorationTheme: new InputDecorationTheme(labelStyle: new TextStyle(color: Color(0xffdddddd)))),
);
}
}
class MainTabWidget extends StatefulWidget {
@override
createState() => new MainTabWidgetState();
}
class MainTabWidgetState extends State<MainTabWidget> {
PageController controller;
var pages = [HomePage(), StockRightsPage(), DealPage(), MinePage()];
var currentIndex = 0;
@override
Widget build(BuildContext context) {
controller = new PageController(initialPage: 0);
return new Scaffold(
body: new PageView.builder(
itemBuilder: (BuildContext context, int index) {
return pages[index];
},
itemCount: pages.length,
onPageChanged: (index) {
print("onPageChanged:$index");
if (currentIndex != index) {
setState(() {
currentIndex = index;
});
}
},
controller: controller,
),
bottomNavigationBar: bottomNavigationBar(),
);
}
Widget bottomNavigationBar() {
return new BottomNavigationBar(
items: [
new BottomNavigationBarItem(
icon: new ImageIcon(
new AssetImage("images/home_menu_home.png"),
size: 48.0,
color: currentIndex == 0 ? Color(0xff0c0435) : Color(0xffb6b6b6),
),
title: new Container()),
new BottomNavigationBarItem(
icon: new ImageIcon(
new AssetImage("images/home_menu_guquan.png"),
size: 48.0,
color: currentIndex == 1 ? Color(0xff0c0435) : Color(0xffb6b6b6),
),
title: new Container()),
new BottomNavigationBarItem(
icon: new ImageIcon(
new AssetImage("images/home_menu_deal.png"),
size: 48.0,
color: currentIndex == 2 ? Color(0xff0c0435) : Color(0xffb6b6b6),
),
title: new Container()),
new BottomNavigationBarItem(
icon: new ImageIcon(
new AssetImage("images/home_menu_mine.png"),
size: 48.0,
color: currentIndex == 3 ? Color(0xff0c0435) : Color(0xffb6b6b6),
),
title: new Container())
],
onTap: (index) {
print("onTap:$index");
controller.animateToPage(index, duration: Duration(milliseconds: 300), curve: Curves.linear);
},
currentIndex: 0,
type: BottomNavigationBarType.fixed,
fixedColor: Color(0xff0c0435),
);
}
}
|
I've fixed the exception issue in the linked PR, it's just still being reviewed/refined. @krmao that's probably a good workaround for most cases, as I think it should force the cause of this bug to not happen - but it wouldn't necessarily work for some cases with larger listviews. |
that's really great ! I will wait the new version of flutter . @dnfield |
I made sample repository here |
This bug has been fixed in v0.8.2-pre.26, just update your flutter version |
I'm running 0.8.2 and I'm facing the same error: @override
Widget build(BuildContext context) {
return new Scaffold(
body: new GridView.count(
primary: false,
padding: const EdgeInsets.all(5.0),
crossAxisSpacing: 1.0,
childAspectRatio: 1.0,
crossAxisCount: 3,
mainAxisSpacing: 8.0,
children: <Widget>[
Expanded(
child: Image.network("https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png", fit:BoxFit.cover),
),
Image.network("https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png"),
const Text('Google'),
],
),
floatingActionButton: new FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Search',
child: new Icon(Icons.search),
backgroundColor: PrimaryColor2,
foregroundColor: Color(0xFFFFFFFF),
),
);
} |
@super94i I'd suggest to create a new issue with a properly filled issue template and a minimal but runnable reproduction. |
Sorry guys, the problem was still there. But I think I've finally found a solution. This bug is triggered when we click on the save button and the keyboard is still in screen. My workaround is hide the keyboard before to call _submitForm method like this: Widget _buildSubmitButton() {
return ScopedModelDescendant<MainModel>(
builder: (BuildContext context, Widget child, MainModel model) {
return model.isLoading
? Center(child: CircularProgressIndicator())
: RaisedButton(
child: Text('Save'),
textColor: Colors.white,
onPressed: () async {
SystemChannels.textInput.invokeMethod('TextInput.hide');
await Future.delayed(const Duration(milliseconds: 100));
_submitForm(model.addProduct, model.updateProduct,
model.selectProduct, model.selectedProductIndex);
},
);
},
);
} |
@Eder87rh this definitely seems like a different issue - can you open a separate issue (feel free to tag me in it) with a minimal reproduction? |
@super94i yours also seems different, but again please feel free to open a separate issue and tag me in it if you like. |
I had the same error and its from the keyboard if you hide they keyboard before submitting the form .it will work . but i want to know is there any solution to go over this probleme |
@mohamedHassanKa please open a new issue with a sample and instructions to reproduce your issue. |
I encountered this issue in current beta.
Here is my workaround code. When tabs are changing, it will unfocus any active widget.
|
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 |
Steps to Reproduce
I have a PageView that contains the top level widgets for my app, with switching between them controlled by a BottomNavBar. As per @Hixie's advice in the chat, I am adding
AutomaticKeepAliveClientMixin
to these top level widgets so the PageView won't recycle them and will preserve state. After I added this to the main widget that contains a network loaded ListView, on occasion when switching back to this ListView from another tab I get this failed assertion in the framework.Logs
Flutter Doctor
The text was updated successfully, but these errors were encountered: