Skip to content

Commit

Permalink
Merge pull request #6 from cb-cloud/performance_issue
Browse files Browse the repository at this point in the history
Prevent rebuild on changed Widget size.
  • Loading branch information
Kurogoma4D authored Jul 27, 2021
2 parents e07d209 + b8f8ecc commit b67f5a1
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 21 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.2
FIX
- Removed `LayoutBuilder` from root of `InfiniteScrollTabView`. This change prevents some performance issue.

## 1.0.1
FIX
- Added `indicatorHeight` property to `InfintieScrollTabView`. It will override indicator height if specified non-null value.
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.0.1"
version: "1.0.2"
lints:
dependency: transitive
description:
Expand Down
46 changes: 27 additions & 19 deletions lib/src/infinite_scroll_tab_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class InfiniteScrollTabView extends StatelessWidget {
this.indicatorHeight,
this.tabHeight = 44.0,
this.tabPadding = 12.0,
this.size,
}) : super(key: key);

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

/// The size constraint of this widget.
///
/// If this is null, then `MediaQuery.of(context).size` is used as default.
/// This value should specify only in some rare case, testing or something
/// like that.
/// Internally this is only used for get page width, but this value determines
/// entire widget's width.
final Size? size;

@override
Widget build(BuildContext context) {
if (indicatorHeight != null) {
assert(indicatorHeight! >= 1.0);
}

return LayoutBuilder(
builder: (context, constraint) => InnerInfiniteScrollTabView(
size: constraint.biggest,
contentLength: contentLength,
tabBuilder: tabBuilder,
pageBuilder: pageBuilder,
onTabTap: onTabTap,
separator: separator,
textScaleFactor: MediaQuery.of(context).textScaleFactor,
defaultTextStyle: DefaultTextStyle.of(context).style,
textDirection: Directionality.of(context),
backgroundColor: backgroundColor,
onPageChanged: onPageChanged,
indicatorColor: indicatorColor,
indicatorHeight: indicatorHeight,
defaultLocale: Localizations.localeOf(context),
tabHeight: tabHeight,
tabPadding: tabPadding,
),
return InnerInfiniteScrollTabView(
size: MediaQuery.of(context).size,
contentLength: contentLength,
tabBuilder: tabBuilder,
pageBuilder: pageBuilder,
onTabTap: onTabTap,
separator: separator,
textScaleFactor: MediaQuery.of(context).textScaleFactor,
defaultTextStyle: DefaultTextStyle.of(context).style,
textDirection: Directionality.of(context),
backgroundColor: backgroundColor,
onPageChanged: onPageChanged,
indicatorColor: indicatorColor,
indicatorHeight: indicatorHeight,
defaultLocale: Localizations.localeOf(context),
tabHeight: tabHeight,
tabPadding: tabPadding,
);
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: infinite_scroll_tab_view
description: A Flutter package for tab view component that can scroll infinitely.
version: 1.0.1
version: 1.0.2
repository: https://github.com/cb-cloud/flutter_infinite_scroll_tab_view

environment:
Expand Down

0 comments on commit b67f5a1

Please sign in to comment.