Skip to content

Commit b67f5a1

Browse files
authored
Merge pull request #6 from cb-cloud/performance_issue
Prevent rebuild on changed Widget size.
2 parents e07d209 + b8f8ecc commit b67f5a1

File tree

4 files changed

+33
-21
lines changed

4 files changed

+33
-21
lines changed

Diff for: CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.0.2
2+
FIX
3+
- Removed `LayoutBuilder` from root of `InfiniteScrollTabView`. This change prevents some performance issue.
4+
15
## 1.0.1
26
FIX
37
- Added `indicatorHeight` property to `InfintieScrollTabView`. It will override indicator height if specified non-null value.

Diff for: example/pubspec.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ packages:
7373
path: ".."
7474
relative: true
7575
source: path
76-
version: "1.0.1"
76+
version: "1.0.2"
7777
lints:
7878
dependency: transitive
7979
description:

Diff for: lib/src/infinite_scroll_tab_view.dart

+27-19
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class InfiniteScrollTabView extends StatelessWidget {
3232
this.indicatorHeight,
3333
this.tabHeight = 44.0,
3434
this.tabPadding = 12.0,
35+
this.size,
3536
}) : super(key: key);
3637

3738
/// A length of tabs and pages.
@@ -104,31 +105,38 @@ class InfiniteScrollTabView extends StatelessWidget {
104105
/// the tabs will have padding as `EdgeInsets.symmetric(horizontal: 12.0)`.
105106
final double tabPadding;
106107

108+
/// The size constraint of this widget.
109+
///
110+
/// If this is null, then `MediaQuery.of(context).size` is used as default.
111+
/// This value should specify only in some rare case, testing or something
112+
/// like that.
113+
/// Internally this is only used for get page width, but this value determines
114+
/// entire widget's width.
115+
final Size? size;
116+
107117
@override
108118
Widget build(BuildContext context) {
109119
if (indicatorHeight != null) {
110120
assert(indicatorHeight! >= 1.0);
111121
}
112122

113-
return LayoutBuilder(
114-
builder: (context, constraint) => InnerInfiniteScrollTabView(
115-
size: constraint.biggest,
116-
contentLength: contentLength,
117-
tabBuilder: tabBuilder,
118-
pageBuilder: pageBuilder,
119-
onTabTap: onTabTap,
120-
separator: separator,
121-
textScaleFactor: MediaQuery.of(context).textScaleFactor,
122-
defaultTextStyle: DefaultTextStyle.of(context).style,
123-
textDirection: Directionality.of(context),
124-
backgroundColor: backgroundColor,
125-
onPageChanged: onPageChanged,
126-
indicatorColor: indicatorColor,
127-
indicatorHeight: indicatorHeight,
128-
defaultLocale: Localizations.localeOf(context),
129-
tabHeight: tabHeight,
130-
tabPadding: tabPadding,
131-
),
123+
return InnerInfiniteScrollTabView(
124+
size: MediaQuery.of(context).size,
125+
contentLength: contentLength,
126+
tabBuilder: tabBuilder,
127+
pageBuilder: pageBuilder,
128+
onTabTap: onTabTap,
129+
separator: separator,
130+
textScaleFactor: MediaQuery.of(context).textScaleFactor,
131+
defaultTextStyle: DefaultTextStyle.of(context).style,
132+
textDirection: Directionality.of(context),
133+
backgroundColor: backgroundColor,
134+
onPageChanged: onPageChanged,
135+
indicatorColor: indicatorColor,
136+
indicatorHeight: indicatorHeight,
137+
defaultLocale: Localizations.localeOf(context),
138+
tabHeight: tabHeight,
139+
tabPadding: tabPadding,
132140
);
133141
}
134142
}

Diff for: pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: infinite_scroll_tab_view
22
description: A Flutter package for tab view component that can scroll infinitely.
3-
version: 1.0.1
3+
version: 1.0.2
44
repository: https://github.com/cb-cloud/flutter_infinite_scroll_tab_view
55

66
environment:

0 commit comments

Comments
 (0)