BilalShahid13 / PersistentBottomNavBar

A highly customizable persistent bottom navigation bar for Flutter
BSD 3-Clause "New" or "Revised" License
506 stars 371 forks source link

On textfield edit keyboard shows briefly before closing #239

Open GodCodeWeed opened 2 years ago

yassinsameh commented 2 years ago

I had the same issue, what worked for me was returning the PersistentTabView directly from the build as opposed to having it inside a Scaffold.

rafaces commented 2 years ago

I was having the same issue; Returning the PersistentTabView directly from the build was not an option for me; Having the a scaffold Key instantiated outside the build method should do the trick:

class _YourWidgetState extends State<YourWidget> {
  final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();

...
...

@override
Widget build(BuildContext context) {
    return Scaffold(
      key: _scaffoldKey,
aymaalo commented 2 years ago

same problem, none of your solutions worked.

AsjadSiddiqui commented 2 years ago

I found a solution, I am using persistent_bottom_nav_bar: ^4.0.2 This happens because of line 371 in the lib/models/persistent-nav-bar-scaffold.widget.dart file

In the _focusActiveTab function:


  void _focusActiveTab() {
    if (widget.screenTransitionAnimation!.animateTabTransition)
      _newPageAnimation();
    if (tabFocusNodes.length != widget.tabCount) {
      if (tabFocusNodes.length > widget.tabCount!) {
        discardedNodes.addAll(tabFocusNodes.sublist(widget.tabCount!));
        tabFocusNodes.removeRange(widget.tabCount!, tabFocusNodes.length);
      } else {
        tabFocusNodes.addAll(
          List<FocusScopeNode>.generate(
            widget.tabCount! - tabFocusNodes.length,
            (int index) => FocusScopeNode(
                debugLabel:
                    '$CupertinoTabScaffold Tab ${index + tabFocusNodes.length}'),
          ),
        );
      }
    }
    // FocusScope.of(context).setFirstFocus(tabFocusNodes[widget.currentTabIndex]);
    if (widget.screenTransitionAnimation!.animateTabTransition)
      _lastPageAnimation();
  }

Commenting out FocusScope.of(context).... line fixes this error, this is the line: FocusScope.of(context).setFirstFocus(tabFocusNodes[widget.currentTabIndex]);

I don't know if this line is important, seems like it is not because I don't notice any other unexpected behavior