GithubHelp home page GithubHelp logo

ayham95 / custom-navigator Goto Github PK

View Code? Open in Web Editor NEW
80.0 2.0 33.0 478 KB

A flutter package that handles navigation deep in the widget tree

License: MIT License

Dart 92.35% Java 3.47% Swift 3.82% Objective-C 0.35%
navigator navigation flutter bottomnavigationview

custom-navigator's People

Contributors

ayham95 avatar jackdreilly avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

custom-navigator's Issues

How not to use your navigator after i already wrap it?

First of all thanks for your great widget, I am able to render the Bottom's Nav inside other pages stack but what if I don't wanna render in some page and would like no bottom navigation because whenever I use those routes it always popup the bottom navigation.

Bottom navigator colors not working

I have used bottom navigator inside the custom navigator and the default colors for the icons on selected and not selected are not working when I try to set a color for selected or unselected item then I get an error saying "unselected color==null || color==null" although I am leaving color as null

Error while Creating build

/C:/Users/syntronic/AppData/Local/Pub/Cache/hosted/pub.dev/custom_top_navigator-0.0.4/lib/custom_top_navigator.dart:192:10: Error: Type 'AppExitResponse' not found.
Future didRequestAppExit() {
^^^^^^^^^^^^^^^
flutter --version
Flutter 3.7.12 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 4d9e56e694 (5 months ago) • 2023-04-17 21:47:46 -0400
Engine • revision 1a65d409c7
Tools • Dart 2.19.6 • DevTools 2.20.1

When I comment inside /Pub/Cache/hosted/pub.dev/custom_top_navigator-0.0.4/lib/custom_top_navigator.dart:192:10: it works
// @OverRide
// Future didRequestAppExit() {
// // TODO: implement didRequestAppExit
// throw UnimplementedError();
// }

Same GlobalKey on all pages

I thought each BottomNavigationBar items should have different navigatorState key. With same globalkey, it may be confuse navigation history.

back button press

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

Custom navigation bottom bar

Good day!

How Can I integrate this plugin with a bottom navigation like this ?

I have some errors trying this

bottomNavigationBar: ClipRRect(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(30.0),
topRight: Radius.circular(30.0),
),
child: BottomNavigationBar(
type: BottomNavigationBarType.fixed,
items: [
BottomNavigationBarItem(
icon: Icon(
Icons.dashboard,
size: 30.0,
color: Colors.black,
),
title: Text(''),
)..

Thank you

CustomScaffold : How to use Navigator.of(context).pushNamed() ?

previous , i want say thank's to make great plugin . I have problem navigate from Page-Testing1 to Detail-Page-Testing1 , I already read the documentation but not found about using pushNamed.


I get error like this after i press button to navigate from Page-Testing1 to Detail-Page-Testing1

Log Error


════════ Exception caught by gesture ═══════════════════════════════════════════
The following assertion was thrown while handling a gesture:
Could not find a generator for route RouteSettings("/detail-page-testing1", null) in the _CustomNavigatorState.

Generators for routes are searched for in the following order:
 1. For the "/" route, the "home" property, if non-null, is used.
 2. Otherwise, the "routes" table is used, if it has an entry for the route.
 3. Otherwise, onGenerateRoute is called. It should return a non-null value for any valid route not handled by "home" and "routes".
 4. Finally if all else fails onUnknownRoute is called.
Unfortunately, onUnknownRoute was not set.
When the exception was thrown, this was the stack
#0      _CustomNavigatorState._onUnknownRoute.<anonymous closure> 
package:custom_navigator/custom_navigator.dart:158
#1      _CustomNavigatorState._onUnknownRoute 
package:custom_navigator/custom_navigator.dart:170
#2      NavigatorState._routeNamed 
package:flutter/…/widgets/navigator.dart:1644
#3      NavigatorState.pushNamed 
package:flutter/…/widgets/navigator.dart:1683
#4      PageTesting1.build.<anonymous closure> 
package:klenger_burger/screens/homescreen.dart:124
...
Handler: "onTap"
Recognizer: TapGestureRecognizer#4f977
    debugOwner: GestureDetector
    state: possible
    won arena
    finalPosition: Offset(177.3, 238.7)
    finalLocalPosition: Offset(82.3, 18.0)
    button: 1
    sent tap down
════════════════════════════════════════════════════════════════════════════════

Custom


class HomeScreenCustom extends StatefulWidget {
  final List<BottomNavigationBarItem> itemMenuBottomNavigation;
  final List<Widget> screenBottomNavigation;
  final Function(int) onTapItemBottomNavigation;
  HomeScreenCustom({
    @required this.onTapItemBottomNavigation,
    @required this.screenBottomNavigation,
    @required this.itemMenuBottomNavigation,
  });
  @override
  _HomeScreenCustomState createState() => _HomeScreenCustomState();
}

class _HomeScreenCustomState extends State<HomeScreenCustom> {
  @override
  Widget build(BuildContext context) {
    return CustomScaffold(
      scaffold: Scaffold(
        bottomNavigationBar: BottomNavigationBar(
          items: widget.itemMenuBottomNavigation,
        ),
      ),

      // 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.screenBottomNavigation,

      // Called when one of the [items] is tapped.
      onItemTap: widget.onTapItemBottomNavigation,
    );
  }

  // 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')),
  // ];
}

HomeScreenCustom

 @override
  Widget build(BuildContext context) {
    return HomeScreenCustom(
      itemMenuBottomNavigation: [
        BottomNavigationBarItem(icon: Icon(Icons.home), title: Text('home')),
        BottomNavigationBarItem(icon: Icon(Icons.event), title: Text('events')),
      ],
      screenBottomNavigation: <Widget>[
        PageTesting1(),
        PageTesting2(),
      ],
      onTapItemBottomNavigation: (index) {},
    );
  }
}

class PageTesting1 extends StatelessWidget {
  static const routeNamed = "/page-testing1";

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: FlatButton(
          onPressed: () =>
              Navigator.of(context).pushNamed(DetailPageTesting1.routeNamed),
          child: Text('Detail Testing 1'),
        ),
      ),
    );
  }
}

class DetailPageTesting1 extends StatelessWidget {
  static const routeNamed = "/detail-page-testing1";
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Text('Detail Testing 1'),
      ),
    );
  }
}

class PageTesting2 extends StatelessWidget {
  static const routeNamed = "/page-testing2";

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: FlatButton(
          onPressed: () =>
              Navigator.of(context).pushNamed(DetailPageTesting2.routeNamed),
          child: Text('Detail Testing 2'),
        ),
      ),
    );
  }
}

class DetailPageTesting2 extends StatelessWidget {
  static const routeNamed = "/detail-page-testing2";

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: Text('Detail Testing 2'),
      ),
    );
  }
}

If i make mistake or i miss something in documentation, please correct me.

Thank's

The non-abstract class '_CustomNavigatorState' is missing implementations

I just updated to the latest flutter beta:

../../../.pub-cache/hosted/pub.dartlang.org/custom_navigator-0.3.0/lib/custom_navigator.dart:60:7: Error: The non-abstract class '_CustomNavigatorState' is missing implementations for these members:

  • WidgetsBindingObserver.didPushRouteInformation
    Try to either
  • provide an implementation,
  • inherit an implementation from a superclass or mixin,
  • mark the class as abstract, or
  • provide a 'noSuchMethod' implementation.

class _CustomNavigatorState extends State
^^^^^^^^^^^^^^^^^^^^^
../../../google/flutter/packages/flutter/lib/src/widgets/binding.dart:122:16: Context: 'WidgetsBindingObserver.didPushRouteInformation' is defined here.
Future didPushRouteInformation(RouteInformation routeInformation) {
^^^^^^^^^^^^^^^^^^^^^^^
Failed to compile application.
Exited (sigterm)

Pop CustomScaffold to naviagate to another route

@ayham95
I need to pop the CustomScaffold and push to another route... when I tried this and set rootNavigator = true, the new route pops up but the back button on android stops working..
My router looks like this
'/login'
'/controller'(which contains the CustomScaffold )

I need to navigate back to '/login' and pop '/controller'..Thanks in Advance

How to preserve page state when a new page is opened

Hi! thank's for making this package as it solves my hours of frustration to make a persistent bottom navbar while navigating on pages.

However, I face difficulties to handle page state when navigating through tabs.

For example:
Supposed that I'm in a homepage, then I clicked the details page. Hence, the homepage is navigating to it's details page. Then, when I'm in the home page's details page, I press another tab and the app is navigating to a new page. But, when I navigating to the homepage again, the page is returned to it's parent page not to details page. I know this happens because we implement navigatorKey.currentState.maybePop(); in the ButtomNavBar's onTap function. Then I tried to comment that line, but what I found is that navigating to another page is not possible since the homepage's details page isn't popped yet.

Another example:
when I'm on a homepage that has a hundred lists, I scroll the page until I reach the end of the list. Then, I'm navigating to another page. But when I'm navigating back to the homepage, I found out that the page is scrolled back to it's first list again. So, how do I preserve the scroll position when navigating through pages?

Thank you, hope my explanation above is clear enough.

Scaffold back button not appear in appBar

Hi,

First, thanks for this package its exactly what we need for our app! I have one small issue,
I'm not able to make the back button appear in the appBar after a navigation.

I'm using CustomNavigator on my Scaffold body and not recreate a Scaffold when I navigate (using Navigator.of(context).push) to a page. The back button of android device works well.

Do you have an idea why it's not refreshing the appBar ?

Thanks,
Max

pushReplacement() and .pop()

Hi,
I have two problems, I use CustomScaffold and I have some tabs in bottom bar.

First case: one of tab is "menu", where I have push to other pages, sth like this:
Navigator.pushReplacement(context, MaterialPageRoute(builder: (cntx) => MyNewPage()))
when I clicked it, screen change but bottom bar is crashed - any click on tab do nothing.

Second case: Changes of tabs doesn't saved history, so back button don't work between tabs of bottom bar. Also I want "close" my menu tab (back to previous tab/screen) in this way Navigator.of(context).pop(); and I have white screen with bottom bar and this same problem like first case...

I have latest version of plugin... Any idea? ;)

Issue regarding popping pages

Thanks for this package, however i face an issue here, i have an app with a signup screen after which the screen with custom Scaffold appears(with the bottom Navbar), in there in my bottom Navbar i have four items, if i am currently in the first screen i.e., the HomePage(corresponding to the first item in Navbar) and i navigate to some other screen on pressing a button(say) which is in the HomePage , the bottom Navbar works perfectly and it remains in the navigated screen, but if i use my androids back button it will go directly to the signup page and not to the HomePage as it should, however if i use the backbutton in the appbar it will go to Homepage as intended, i dont know if everyone is facing this issue or i am the only one??

Add 4 BottomNavigationBarItem

How to add 4 BottomNavigationBarItem ?
if I add in
final _items = [ BottomNavigationBarItem(icon: Icon(Icons.home), title: Text('Home')), BottomNavigationBarItem(icon: Icon(Icons.phone_iphone), title: Text('Tentang')), BottomNavigationBarItem(icon: Icon(Icons.email), title: Text('Kontak')), BottomNavigationBarItem(icon: Icon(Icons.person_pin), title: Text('Akun')), ];
lost BottomNavigationBar in my design

when click bottom navigation icon, navigator does not direct push to that screen.

`
import 'package:capp/scopped-model/main_model.dart';
import 'package:capp/screens/about_papertale_screen.dart';
import 'package:capp/screens/dashboard_screen.dart';
import 'package:custom_navigator/custom_navigator.dart';
import 'package:flutter/material.dart';

class HomeScreen extends StatefulWidget {
final MainModel model;

HomeScreen({this.model});

@OverRide
_HomeScreenState createState() => _HomeScreenState();
}

class _HomeScreenState extends State {
GlobalKey navigatorKey = GlobalKey();
int _currentIndex = 0;

@OverRide
Widget build(BuildContext context) {
final tabpages = [
DashboardScreen(
model: widget.model,
),
AboutPaperTaleScreen(
model: widget.model,
),
AboutPaperTaleScreen(
model: widget.model,
),
];
return Scaffold(
bottomNavigationBar: BottomNavigationBar(
backgroundColor: Colors.white,
currentIndex: _currentIndex,
unselectedItemColor: Theme.of(context).primaryColor.withOpacity(0.5),
selectedItemColor: Theme.of(context).primaryColor,
items: _items,
onTap: (index) {
// if (index == 0) {
navigatorKey.currentState.maybePop();
// }
setState(() {
_currentIndex = index;
});
},
),
body: CustomNavigator(
navigatorKey: navigatorKey,
home: tabpages[_currentIndex],
pageRoute: PageRoutes.materialPageRoute,
),
);
}

final _items = [
BottomNavigationBarItem(
icon: Icon(Icons.home),
title: Text(''),
),
BottomNavigationBarItem(
icon: Icon(Icons.info_outline),
title: Text(''),
),
BottomNavigationBarItem(
icon: Icon(Icons.settings),
title: Text(''),
),
];
}
`

when click on bottom bar icon, navigator pop the route but i want to direct push to desired screen

Use a different navigator widget

Hey, is there a way to use a different bottom navigation bar with customscaffold? I want to use bottomnavybar instead of the default one

hide navigation bar

is there any way to hide the bottom navigation bar on some specific page?

Can't selected item color

Hi, thank you for this awesome package It literally makes my life easier but I faced an issue that I can't choose a color for an item.
Capture
Capturedd

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.