PersistentBottomNavBarV2 icon indicating copy to clipboard operation
PersistentBottomNavBarV2 copied to clipboard

rebuilld

Open json1994 opened this issue 2 years ago • 1 comments

at keyboard height changed will be rebuild

json1994 avatar Jul 14 '22 08:07 json1994

Yes because e.g. the layout of the screen has to be recalculated. Does that break something for you?

jb3rndt avatar Jul 28 '22 11:07 jb3rndt

@jb3rndt I have an issue with rebuilding on other screens when the keyboard pops up on one screen.

Here is how my widgets are arranged;


class CustomNavBar extends StatefulWidget {
  const CustomNavBar({Key? key, required this.initialPage}) : super(key: key);

  final int initialPage;

  @override
  State<CustomNavBar> createState() => _CustomNavBarState();
}

class _CustomNavBarState extends State<CustomNavBar> {
  late PersistentTabController _controller;

  @override
  void initState() {
    _controller = PersistentTabController(initialIndex: widget.initialPage);
    super.initState();
  }

  List<Widget> _buildScreens() {
    return [
      const Screen1(),
      const Screen2(),
      const Screen3(),
    ];
  }

  ...

  @override
  Widget build(BuildContext context) {
            return PersistentTabView(
              context,
              controller: _controller,
              screens: _buildScreens(),
              ...
              handleAndroidBackButtonPress: true, // Default is true.
              resizeToAvoidBottomInset: false, 
              stateManagement: true, // Default is true.
              hideNavigationBarWhenKeyboardShows: true,
              popAllScreensOnTapOfSelectedTab: false,
              // popActionScreens: PopActionScreensType.once,
             
   );
  }
}

When I open the keyboard on screen 2, other screens would rebuild, and I lose the state of the screen. For example, on screen 3, I have pageview which will reset after calling the keyboard on screen 2.

ZahraVe avatar Feb 15 '23 14:02 ZahraVe

I tried reproducing your issue, but didnt observe what you described. Can you send a full minimal example that doesnt work?

jb3rndt avatar Feb 27 '23 22:02 jb3rndt

@jb3rndt I have managed to keep the state of the page that I wanted to. Still, the build method of the screens would be called whenever the keyboard moves. I will try to make a minimal example and share it here.

ZahraVe avatar Feb 28 '23 11:02 ZahraVe