ayham95 / Custom-navigator

A flutter package that handles navigation deep in the widget tree
MIT License
80 stars 33 forks source link

back button press #8

Closed rezam92 closed 4 years ago

rezam92 commented 5 years ago

is it possible to handle back press button in android? now, in each tab when i press back button, it results in exiting app. i need to exit app just in one tab, for example home

ayham95 commented 5 years ago

Are you using the CustomNavigator or the CustomScaffold?

rezam92 commented 5 years ago

I use CustomNavigator ,like a example

rezam92 commented 5 years ago

I use CustomNavigator ,like a example

I used CustomScaffold too, it is the same as CustomNavigator, app exit with press back button in any tab

ayham95 commented 4 years ago

This is weird can i see your implementation ??

runwidgetdeveloper commented 4 years ago

Yes, I just implemented your example.

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;
  @override
  _MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
  // Custom navigator takes a global key if you want to access the
  // navigator from outside it's widget tree subtree
  GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
  @override
  Widget build(BuildContext context) {
    // Here's the custom scaffold widget
    // It takes a normal scaffold with mandatory bottom navigation bar
    // and children who are your pages
    return CustomScaffold(
      scaffold: Scaffold(
        bottomNavigationBar: BottomNavigationBar(
          items: _items,
        ),
      ),
      // Children are the pages that will be shown by every click
      // They should placed in order such as
      // `page 0` will be presented when `item 0` in the [BottomNavigationBar] clicked.
      children: <Widget>[
        Page('0'),
        Page('1'),
        Page('2'),
      ],
      // Called when one of the [items] is tapped.
      onItemTap: (index) {},
    );
  }
  final _items = [
    BottomNavigationBarItem(icon: Icon(Icons.home), title: Text('home')),
    BottomNavigationBarItem(icon: Icon(Icons.event), title: Text('events')),
    BottomNavigationBarItem(
        icon: Icon(Icons.save_alt), title: Text('downloads')),
  ];
}

in each page if I press back in android, app will be closed.

ayham95 commented 4 years ago

i wasn't able to reproduce the problem even on Android. It works fine on Android and IOS are you sure you're on the latest version?

rezam92 commented 4 years ago

thank you @ayham95 . It's ok on the latest version.

somkar99 commented 3 years ago

it is still giving the same issue im using the custom navigator

somkar99 commented 3 years ago

Same issue