Giter Site home page Giter Site logo

Comments (11)

jamesderlin avatar jamesderlin commented on May 30, 2024 1

@pedromassango Is it not a problem that TitledBottomNavigationBar does both super(key: key) and SafeArea(child: Container(key: widget.key,? Seems like that might be a bad thing to do with a GlobalKey?

from titled_navigation_bar.

pedromassango avatar pedromassango commented on May 30, 2024

it seems that you are tying to reuse a key. Keys must be unique across the app.

See the last line's cooment:

" A GlobalKey can only be specified on one widget at a time in the widget tree"

from titled_navigation_bar.

sukhcha-in avatar sukhcha-in commented on May 30, 2024

@pedromassango no, i am creating key in stateful widget and using it only inside navigation bar. Still i'm out of clue why it is showing error.

from titled_navigation_bar.

pedromassango avatar pedromassango commented on May 30, 2024

As the message says, you are using it more than once

from titled_navigation_bar.

sukhcha-in avatar sukhcha-in commented on May 30, 2024

@pedromassango Here's my code please have a look:

import 'package:flutter/material.dart';
import 'package:titled_navigation_bar/titled_navigation_bar.dart';

class TesterPage extends StatefulWidget {
  @override
  _TesterPageState createState() => _TesterPageState();
}

class _TesterPageState extends State<TesterPage> {
  final GlobalKey _navigationBarKey = GlobalKey();
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      bottomNavigationBar: TitledBottomNavigationBar(
        key: _navigationBarKey,
        onTap: (int index) {
          print(index.toString());
        },
        items: [
          TitledNavigationBarItem(title: 'Home', icon: Icons.home),
          TitledNavigationBarItem(title: 'Help', icon: Icons.help),
          TitledNavigationBarItem(title: 'Account', icon: Icons.person),
        ],
      ),
      body: Center(
        child: RaisedButton(
          child: Text("Test"),
          onPressed: () {
            final TitledBottomNavigationBar navigationBar = _navigationBarKey.currentWidget;
            navigationBar.onTap(1);
          },
        ),
      ),
    );
  }
}

from titled_navigation_bar.

sukhcha-in avatar sukhcha-in commented on May 30, 2024

@jamesderlin any possible solution for my issue? I want to navigate to other tab of navigation bar programmatically. i used global key because i of .currentWidget property

from titled_navigation_bar.

sukhcha-in avatar sukhcha-in commented on May 30, 2024

@pedromassango Please do something for this. I want to achieve this: Image of Yaktocat

from titled_navigation_bar.

pedromassango avatar pedromassango commented on May 30, 2024

Thanks @jamesderlin. I fixed it on the latest version

from titled_navigation_bar.

pedromassango avatar pedromassango commented on May 30, 2024

@sukhcha-in are you using any state management pattern like Bloc or Redux?

from titled_navigation_bar.

sukhcha-in avatar sukhcha-in commented on May 30, 2024

@pedromassango no, i am just using in built state functions.

from titled_navigation_bar.

sukhcha-in avatar sukhcha-in commented on May 30, 2024

@pedromassango Thanks for recent update :) solved this without even using a key.

from titled_navigation_bar.

Related Issues (20)

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.