Skip to content

Commit

Permalink
Merge pull request #135 from hacktons/f-fix-compile-error
Browse files Browse the repository at this point in the history
[WIP] fix compile error
  • Loading branch information
avenwu committed Feb 23, 2021
2 parents ef34f16 + 02e8d85 commit 02a6275
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## [2.7.1+1]
* Bug fix [Manual update tab index workaround seems not working since version 2.7.x](https://github.com/hacktons/convex_bottom_bar/issues/134)

## [2.7.1]
* fix runtime exception when there is no controller passed in

Expand Down
15 changes: 9 additions & 6 deletions lib/src/bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class ConvexAppBar extends StatefulWidget {
final Gradient gradient;

/// The initial active index, you can config initialIndex of [TabController] if work with [TabBarView] or [PageView].
/// If controller exists, use controller.index instead of initialActiveIndex.
final int initialActiveIndex;

/// Disable access of DefaultTabController to avoid unexpected conflict.
Expand Down Expand Up @@ -253,7 +254,7 @@ class ConvexAppBar extends StatefulWidget {
@required this.itemBuilder,
@required this.count,
this.initialActiveIndex,
this.disableDefaultTabController,
this.disableDefaultTabController = false,
this.onTap,
this.onTapNotify,
this.controller,
Expand Down Expand Up @@ -384,6 +385,7 @@ class ConvexAppBarState extends State<ConvexAppBar>
' background display with topLeft/topRight corner'),
]);
}
_resetState();
super.initState();
}

Expand Down Expand Up @@ -495,9 +497,9 @@ class ConvexAppBarState extends State<ConvexAppBar>
}

void _resetState() {
_updateTabController();
var index = widget.initialActiveIndex ?? _controller?.index;
_currentIndex = index;
var index = _controller?.index ?? widget.initialActiveIndex;
// when both initialActiveIndex and controller are not configured
_currentIndex = index ?? 0;

if (!isFixed() && _controller != null) {
// when controller is not defined, the default index can rollback to 0
Expand All @@ -509,8 +511,8 @@ class ConvexAppBarState extends State<ConvexAppBar>
@override
void didChangeDependencies() {
super.didChangeDependencies();
// init state here so we can take a reference of DefaultTabController
if (_controller == null || _controller != _takeControllerRef) {
if (_controller != _takeControllerRef) {
_updateTabController();
_resetState();
}
}
Expand All @@ -520,6 +522,7 @@ class ConvexAppBarState extends State<ConvexAppBar>
super.didUpdateWidget(oldWidget);
if (widget.controller != oldWidget.controller ||
widget.count != oldWidget.count) {
_updateTabController();
_resetState();
}
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: convex_bottom_bar
description: A Flutter package which implements a ConvexAppBar to show a convex tab in the bottom bar. Theming supported.
version: 2.7.1
version: 2.7.1+1
homepage: https://github.com/hacktons/convex_bottom_bar

environment:
Expand Down

0 comments on commit 02a6275

Please sign in to comment.