Skip to content

Commit 78d0cca

Browse files
Muhammad UsmanCopilot
andcommitted
fix persistance condition to remove the widget duplication
Co-authored-by: Copilot <copilot@github.com>
1 parent 84c09e2 commit 78d0cca

1 file changed

Lines changed: 7 additions & 16 deletions

File tree

modules/ensemble/lib/layout/tab_bar.dart

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,12 @@ class TabBarState extends BaseTabBarState {
272272
// https://stackoverflow.com/questions/55425804/using-builder-instead-of-statelesswidget
273273
Widget tabContent = Builder(
274274
key: UniqueKey(),
275-
builder: (BuildContext context) => buildSelectedTab());
275+
builder: (BuildContext context) {
276+
if (widget._controller.persistentTabBar) {
277+
return SingleChildScrollView(child: buildSelectedTab());
278+
}
279+
return buildSelectedTab();
280+
});
276281
if (isExpanded) {
277282
tabContent = Expanded(child: tabContent);
278283
}
@@ -285,21 +290,7 @@ class TabBarState extends BaseTabBarState {
285290
// is sub-optimal since it recreates the tab content on each pass.
286291
// This means onLoad API may be called multiple times in debug mode
287292

288-
widget._controller.persistentTabBar
289-
? (isExpanded
290-
? Expanded(
291-
child: Builder(
292-
key: UniqueKey(),
293-
builder: (BuildContext context) =>
294-
SingleChildScrollView(child: buildSelectedTab()),
295-
),
296-
)
297-
: Builder(
298-
key: UniqueKey(),
299-
builder: (BuildContext context) =>
300-
SingleChildScrollView(child: buildSelectedTab()),
301-
))
302-
: tabContent,
293+
tabContent,
303294

304295
// This cause Expanded child to fail
305296
// Padding(

0 commit comments

Comments
 (0)