circular_bottom_navigation icon indicating copy to clipboard operation
circular_bottom_navigation copied to clipboard

Exception caught by foundation library

Open raegartargarian opened this issue 5 years ago • 1 comments

I did not do much and I was trying to use this library as I got this error:

════════ Exception caught by foundation library ════════════════════════════════ The following NoSuchMethodError was thrown while dispatching notifications for CircularBottomNavigationController: The getter 'value' was called on null. Receiver: null Tried calling: value

here is my page:

import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:visitor_app/screens/add_user_page/screen/add_user_page.dart'; import 'package:visitor_app/screens/home_page/screen/home_page.dart'; import 'package:visitor_app/screens/map_page/screen/map_page.dart'; import 'package:visitor_app/screens/my_users_page/screen/my_users_page.dart'; import 'package:visitor_app/screens/profile_page/screen/profile_page.dart'; import 'package:visitor_app/utils/screen_utils/connection_alert_widget.dart'; import 'package:visitor_app/utils/screen_utils/connection_service.dart'; import 'package:circular_bottom_navigation/circular_bottom_navigation.dart'; import 'package:circular_bottom_navigation/tab_item.dart';

class MainPage extends StatefulWidget { final int tab; MainPage({this.tab}); @override _MainPageState createState() => _MainPageState(); }

class _MainPageState extends State<MainPage> { AddUserPage addUserPage; MapPage mapPage; MyUsersPage myUsersPage; ProfilePage profilePage; HomePage homePage; List<Widget> pages; Widget currentPage;

@override void initState() { final connectionStatus = ConnectionStatusSingleton.getInstance(); addUserPage = new AddUserPage(); mapPage = new MapPage(); myUsersPage = new MyUsersPage(); profilePage = new ProfilePage(); homePage = new HomePage(); pages = [mapPage, addUserPage, homePage, myUsersPage, profilePage]; currentPage = widget.tab == null ? homePage : pages[widget.tab]; connectionStatus.initialize(); super.initState(); }

@override Widget build(BuildContext context) { return WillPopScope( onWillPop: () {}, child: Scaffold( body: Stack( children: <Widget>[currentPage, ConnectionAlertWidget()], ), bottomNavigationBar: CircularBottomNavigation( List.of([ TabItem(Icons.home, "Home", Colors.black, labelStyle: TextStyle(fontFamily: "Ir")), TabItem(Icons.search, "Search", Colors.black, labelStyle: TextStyle(fontFamily: "Ir")), TabItem(Icons.shopping_cart, "Basket", Colors.black, labelStyle: TextStyle(fontFamily: "Ir")), TabItem(Icons.search, "Search", Colors.black, labelStyle: TextStyle(fontFamily: "Ir")), TabItem(Icons.search, "Search", Colors.black, labelStyle: TextStyle(fontFamily: "Ir")), ]), selectedCallback: (position) { print(position); // setState(() { // currentPage = pages[position]; // }); }, ))); }

}

raegartargarian avatar Nov 05 '19 15:11 raegartargarian

You need to attach an existing CircularBottomNavigationController to the controller of the CircularBottomNavigation

makss68 avatar Nov 06 '19 00:11 makss68