i am getting an error bottom navigation bar Widget in flutter

so i am having this error

══════ Exception caught by widgets library ═══════════════════════════════════ ‘package:flutter/src/widgets/framework.dart’: Failed assertion: line 6750 pos 12: ‘child == _child’: is not true.

The relevant error-causing widget was:

════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by widgets library ═══════════════════════════════════ Duplicate GlobalKey detected in widget tree. ════════════════════════════════════════════════════════════════════════════════

and the navigation bar is not working it is not direct me to the pages I want and it keeps lagging .. can anyone help me I’ve seen lot of youtube videos but I cant see the problem …

this is my navigation bar code

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>import 'dart:ffi';
import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:curved_navigation_bar/curved_navigation_bar.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:google_nav_bar/google_nav_bar.dart';
import 'package:notify_ju/Screens/categories.dart';
import 'package:notify_ju/Screens/myReports.dart';
class BottomNavigationBarWidget extends StatefulWidget {
@override
State<BottomNavigationBarWidget> createState() =>
_BottomNavigationBarWidgetState();
}
class _BottomNavigationBarWidgetState extends State<BottomNavigationBarWidget> {
int currentIndex = 0;
void _nav(int index) {
setState(() {
currentIndex = index;
});
}
final screen = [Categories(), const MyReports()];
@override
Widget build(BuildContext context) {
return GNav(
backgroundColor: const Color.fromARGB(255, 195, 235, 197),
activeColor: Color.fromARGB(255, 136, 135, 135),
color: Colors.white,
gap: 3,
selectedIndex: currentIndex,
onTabChange: _nav,
tabs: [
GButton(
icon: Icons.home,
text: 'Home',
),
GButton(
icon: Icons.notifications,
text: 'My Reports',
),
],
);
}
}
</code>
<code>import 'dart:ffi'; import 'package:cloud_firestore/cloud_firestore.dart'; import 'package:curved_navigation_bar/curved_navigation_bar.dart'; import 'package:flutter/material.dart'; import 'package:flutter/widgets.dart'; import 'package:google_nav_bar/google_nav_bar.dart'; import 'package:notify_ju/Screens/categories.dart'; import 'package:notify_ju/Screens/myReports.dart'; class BottomNavigationBarWidget extends StatefulWidget { @override State<BottomNavigationBarWidget> createState() => _BottomNavigationBarWidgetState(); } class _BottomNavigationBarWidgetState extends State<BottomNavigationBarWidget> { int currentIndex = 0; void _nav(int index) { setState(() { currentIndex = index; }); } final screen = [Categories(), const MyReports()]; @override Widget build(BuildContext context) { return GNav( backgroundColor: const Color.fromARGB(255, 195, 235, 197), activeColor: Color.fromARGB(255, 136, 135, 135), color: Colors.white, gap: 3, selectedIndex: currentIndex, onTabChange: _nav, tabs: [ GButton( icon: Icons.home, text: 'Home', ), GButton( icon: Icons.notifications, text: 'My Reports', ), ], ); } } </code>
import 'dart:ffi';

import 'package:cloud_firestore/cloud_firestore.dart';
import 'package:curved_navigation_bar/curved_navigation_bar.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:google_nav_bar/google_nav_bar.dart';
import 'package:notify_ju/Screens/categories.dart';
import 'package:notify_ju/Screens/myReports.dart';

class BottomNavigationBarWidget extends StatefulWidget {
  @override
  State<BottomNavigationBarWidget> createState() =>
      _BottomNavigationBarWidgetState();
}

class _BottomNavigationBarWidgetState extends State<BottomNavigationBarWidget> {
  int currentIndex = 0;
  void _nav(int index) {
    setState(() {
      currentIndex = index;
    });
  }

  final screen = [Categories(), const MyReports()];

  @override
  Widget build(BuildContext context) {
    return GNav(
      backgroundColor: const Color.fromARGB(255, 195, 235, 197),
      activeColor: Color.fromARGB(255, 136, 135, 135),
      color: Colors.white,
      gap: 3,
      selectedIndex: currentIndex,
      onTabChange: _nav,
      tabs: [
        GButton(
          icon: Icons.home,
          text: 'Home',
        ),
        GButton(
          icon: Icons.notifications,
          text: 'My Reports',
        ),
      ],
    );
  }
}

this is myReport page ..

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:notify_ju/Controller/ReportsController.dart';
import 'package:notify_ju/Widgets/bottomNavBar.dart';
import 'package:notify_ju/Widgets/drawer.dart';
class MyReports extends StatefulWidget {
const MyReports({Key? key}) : super(key: key);
@override
State<MyReports> createState() => _MyReportsState();
}
final controller = Get.put(ReportsController());
class _MyReportsState extends State<MyReports> {
@override
Widget build(BuildContext context) {
return Scaffold(
drawer: DrawerWidget(),
backgroundColor: const Color(0xFFEFF5EA),
appBar: AppBar(
centerTitle: true,
title: const Text('My Reports'),
),
body: FutureBuilder(
future: controller.viewCurrentReports(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return const Center(child: CircularProgressIndicator());
} else {
if (snapshot.hasError) {
return const Center(child: Text("Error fetching reports"));
} else {
if (snapshot.data == null || snapshot.data!.isEmpty) {
return const Center(
child: Text("You don't have any reports yet"));
} else {
return ListView.builder(
itemCount: snapshot.data!.length,
itemBuilder: (context, index) {
final items = snapshot.data!;
return Dismissible(
key: UniqueKey(),
background: Container(
color: Colors.red,
child: const Align(
alignment: Alignment.centerLeft,
child: Padding(
padding: EdgeInsets.only(left: 20.0),
child: Icon(
Icons.delete,
color: Colors.white,
),
),
),
),
secondaryBackground: Container(
color: Colors.blue,
child: const Align(
alignment: Alignment.centerRight,
child: Padding(
padding: EdgeInsets.only(right: 20.0),
child: Icon(
Icons.edit,
color: Colors.white,
),
),
),
),
onDismissed: (direction) {
if (direction == DismissDirection.startToEnd) {
controller.deleteReport(items[index]["report_id"]);
} else if (direction == DismissDirection.endToStart) {
//edit item stuff
}
},
child: Card(
color: Color.fromARGB(184, 211, 207, 207),
child: ListTile(
title: Text(items[index]['report_type']),
subtitle: Text(items[index]['incident_description']),
onTap: () {
// Handle tapping on the card
},
),
),
);
},
);
}
}
}
},
),
bottomNavigationBar: BottomNavigationBarWidget(),
);
}
}
</code>
<code>import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:notify_ju/Controller/ReportsController.dart'; import 'package:notify_ju/Widgets/bottomNavBar.dart'; import 'package:notify_ju/Widgets/drawer.dart'; class MyReports extends StatefulWidget { const MyReports({Key? key}) : super(key: key); @override State<MyReports> createState() => _MyReportsState(); } final controller = Get.put(ReportsController()); class _MyReportsState extends State<MyReports> { @override Widget build(BuildContext context) { return Scaffold( drawer: DrawerWidget(), backgroundColor: const Color(0xFFEFF5EA), appBar: AppBar( centerTitle: true, title: const Text('My Reports'), ), body: FutureBuilder( future: controller.viewCurrentReports(), builder: (context, snapshot) { if (snapshot.connectionState == ConnectionState.waiting) { return const Center(child: CircularProgressIndicator()); } else { if (snapshot.hasError) { return const Center(child: Text("Error fetching reports")); } else { if (snapshot.data == null || snapshot.data!.isEmpty) { return const Center( child: Text("You don't have any reports yet")); } else { return ListView.builder( itemCount: snapshot.data!.length, itemBuilder: (context, index) { final items = snapshot.data!; return Dismissible( key: UniqueKey(), background: Container( color: Colors.red, child: const Align( alignment: Alignment.centerLeft, child: Padding( padding: EdgeInsets.only(left: 20.0), child: Icon( Icons.delete, color: Colors.white, ), ), ), ), secondaryBackground: Container( color: Colors.blue, child: const Align( alignment: Alignment.centerRight, child: Padding( padding: EdgeInsets.only(right: 20.0), child: Icon( Icons.edit, color: Colors.white, ), ), ), ), onDismissed: (direction) { if (direction == DismissDirection.startToEnd) { controller.deleteReport(items[index]["report_id"]); } else if (direction == DismissDirection.endToStart) { //edit item stuff } }, child: Card( color: Color.fromARGB(184, 211, 207, 207), child: ListTile( title: Text(items[index]['report_type']), subtitle: Text(items[index]['incident_description']), onTap: () { // Handle tapping on the card }, ), ), ); }, ); } } } }, ), bottomNavigationBar: BottomNavigationBarWidget(), ); } } </code>
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:notify_ju/Controller/ReportsController.dart';
import 'package:notify_ju/Widgets/bottomNavBar.dart';
import 'package:notify_ju/Widgets/drawer.dart';

class MyReports extends StatefulWidget {
  const MyReports({Key? key}) : super(key: key);
  @override
  State<MyReports> createState() => _MyReportsState();
}

final controller = Get.put(ReportsController());

class _MyReportsState extends State<MyReports> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      drawer: DrawerWidget(),
      backgroundColor: const Color(0xFFEFF5EA),
      appBar: AppBar(
        centerTitle: true,
        title: const Text('My Reports'),
      ),
      body: FutureBuilder(
        future: controller.viewCurrentReports(),
        builder: (context, snapshot) {
          if (snapshot.connectionState == ConnectionState.waiting) {
            return const Center(child: CircularProgressIndicator());
          } else {
            if (snapshot.hasError) {
              return const Center(child: Text("Error fetching reports"));
            } else {
              if (snapshot.data == null || snapshot.data!.isEmpty) {
                return const Center(
                    child: Text("You don't have any reports yet"));
              } else {
                return ListView.builder(
                  itemCount: snapshot.data!.length,
                  itemBuilder: (context, index) {
                    final items = snapshot.data!;
                    return Dismissible(
                      key: UniqueKey(),
                      background: Container(
                        color: Colors.red,
                        child: const Align(
                          alignment: Alignment.centerLeft,
                          child: Padding(
                            padding: EdgeInsets.only(left: 20.0),
                            child: Icon(
                              Icons.delete,
                              color: Colors.white,
                            ),
                          ),
                        ),
                      ),
                      secondaryBackground: Container(
                        color: Colors.blue,
                        child: const Align(
                          alignment: Alignment.centerRight,
                          child: Padding(
                            padding: EdgeInsets.only(right: 20.0),
                            child: Icon(
                              Icons.edit,
                              color: Colors.white,
                            ),
                          ),
                        ),
                      ),
                      onDismissed: (direction) {
                        if (direction == DismissDirection.startToEnd) {
                          controller.deleteReport(items[index]["report_id"]);
                        } else if (direction == DismissDirection.endToStart) {
                          //edit item stuff
                        }
                      },
                      child: Card(
                        color: Color.fromARGB(184, 211, 207, 207),
                        child: ListTile(
                          title: Text(items[index]['report_type']),
                          subtitle: Text(items[index]['incident_description']),
                          onTap: () {
                            // Handle tapping on the card
                          },
                        ),
                      ),
                    );
                  },
                );
              }
            }
          }
        },
      ),
      bottomNavigationBar: BottomNavigationBarWidget(),
    );
  }
}

this is my categories page

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>// ignore_for_file: sized_box_for_whitespace
import 'package:flutter/material.dart';
import 'package:google_nav_bar/google_nav_bar.dart';
import 'package:notify_ju/Screens/AddReport.dart';
import 'package:notify_ju/Widgets/bottomNavBar.dart';
import 'package:notify_ju/Widgets/drawer.dart';
class Categories extends StatelessWidget {
final List<String> image = [
'images/fight123.jpg',
'images/fiire.webp',
'images/carss.png',
'images/doggg.png',
'images/injuryy.png',
'images/infraa.png',
];
final List<String> names = [
'Fight',
'Fire',
'Car Accident',
'Stray Animals',
'Injury',
'Infrastructure Damage',
];
Categories({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
drawer: DrawerWidget(),
backgroundColor: const Color(0xFFEFF5EA),
appBar: AppBar(
centerTitle: true,
title: const Text('Choose a Category',
style: TextStyle(
color: Color.fromARGB(255, 0, 0, 0),
fontStyle: FontStyle.italic)),
backgroundColor: const Color.fromARGB(255, 195, 235, 197),
),
body: SingleChildScrollView(
child: Column(
children: [
GridView.count(
crossAxisCount: 2,
crossAxisSpacing: 5.0,
mainAxisSpacing: 5.0,
clipBehavior: Clip.antiAlias,
shrinkWrap: true,
physics: const NeverScrollableScrollPhysics(),
children: List.generate(
image.length,
(index) => Container(
padding: const EdgeInsets.all(3),
child: ElevatedButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => addReport(
reportType: names[index],
),
),
);
},
style: ElevatedButton.styleFrom(
backgroundColor: Colors.white,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(50),
),
),
child: Column(
children: [
const SizedBox(height: 15),
Container(
height: 110,
child: Image.asset(image[index],
fit: BoxFit.fitHeight,
scale: 1.0,
alignment: Alignment.center),
),
const SizedBox(height: 15),
Text(names[index],
style: const TextStyle(
fontSize: 16, color: Colors.black),
textAlign: TextAlign.center),
],
),
),
),
),
),
],
),
),
bottomNavigationBar: BottomNavigationBarWidget(),
);
}
}
</code>
<code>// ignore_for_file: sized_box_for_whitespace import 'package:flutter/material.dart'; import 'package:google_nav_bar/google_nav_bar.dart'; import 'package:notify_ju/Screens/AddReport.dart'; import 'package:notify_ju/Widgets/bottomNavBar.dart'; import 'package:notify_ju/Widgets/drawer.dart'; class Categories extends StatelessWidget { final List<String> image = [ 'images/fight123.jpg', 'images/fiire.webp', 'images/carss.png', 'images/doggg.png', 'images/injuryy.png', 'images/infraa.png', ]; final List<String> names = [ 'Fight', 'Fire', 'Car Accident', 'Stray Animals', 'Injury', 'Infrastructure Damage', ]; Categories({super.key}); @override Widget build(BuildContext context) { return Scaffold( drawer: DrawerWidget(), backgroundColor: const Color(0xFFEFF5EA), appBar: AppBar( centerTitle: true, title: const Text('Choose a Category', style: TextStyle( color: Color.fromARGB(255, 0, 0, 0), fontStyle: FontStyle.italic)), backgroundColor: const Color.fromARGB(255, 195, 235, 197), ), body: SingleChildScrollView( child: Column( children: [ GridView.count( crossAxisCount: 2, crossAxisSpacing: 5.0, mainAxisSpacing: 5.0, clipBehavior: Clip.antiAlias, shrinkWrap: true, physics: const NeverScrollableScrollPhysics(), children: List.generate( image.length, (index) => Container( padding: const EdgeInsets.all(3), child: ElevatedButton( onPressed: () { Navigator.push( context, MaterialPageRoute( builder: (context) => addReport( reportType: names[index], ), ), ); }, style: ElevatedButton.styleFrom( backgroundColor: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(50), ), ), child: Column( children: [ const SizedBox(height: 15), Container( height: 110, child: Image.asset(image[index], fit: BoxFit.fitHeight, scale: 1.0, alignment: Alignment.center), ), const SizedBox(height: 15), Text(names[index], style: const TextStyle( fontSize: 16, color: Colors.black), textAlign: TextAlign.center), ], ), ), ), ), ), ], ), ), bottomNavigationBar: BottomNavigationBarWidget(), ); } } </code>
// ignore_for_file: sized_box_for_whitespace

import 'package:flutter/material.dart';
import 'package:google_nav_bar/google_nav_bar.dart';
import 'package:notify_ju/Screens/AddReport.dart';
import 'package:notify_ju/Widgets/bottomNavBar.dart';
import 'package:notify_ju/Widgets/drawer.dart';

class Categories extends StatelessWidget {
  final List<String> image = [
    'images/fight123.jpg',
    'images/fiire.webp',
    'images/carss.png',
    'images/doggg.png',
    'images/injuryy.png',
    'images/infraa.png',
  ];

  final List<String> names = [
    'Fight',
    'Fire',
    'Car Accident',
    'Stray Animals',
    'Injury',
    'Infrastructure Damage',
  ];

  Categories({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      drawer: DrawerWidget(),
      backgroundColor: const Color(0xFFEFF5EA),
      appBar: AppBar(
        centerTitle: true,
        title: const Text('Choose a Category',
            style: TextStyle(
                color: Color.fromARGB(255, 0, 0, 0),
                fontStyle: FontStyle.italic)),
        backgroundColor: const Color.fromARGB(255, 195, 235, 197),
      ),
      body: SingleChildScrollView(
        child: Column(
          children: [
            GridView.count(
              crossAxisCount: 2,
              crossAxisSpacing: 5.0,
              mainAxisSpacing: 5.0,
              clipBehavior: Clip.antiAlias,
              shrinkWrap: true,
              physics: const NeverScrollableScrollPhysics(),
              children: List.generate(
                image.length,
                (index) => Container(
                  padding: const EdgeInsets.all(3),
                  child: ElevatedButton(
                    onPressed: () {
                      Navigator.push(
                        context,
                        MaterialPageRoute(
                          builder: (context) => addReport(
                            reportType: names[index],
                          ),
                        ),
                      );
                    },
                    style: ElevatedButton.styleFrom(
                      backgroundColor: Colors.white,
                      shape: RoundedRectangleBorder(
                        borderRadius: BorderRadius.circular(50),
                      ),
                    ),
                    child: Column(
                      children: [
                        const SizedBox(height: 15),
                        Container(
                          height: 110,
                          child: Image.asset(image[index],
                              fit: BoxFit.fitHeight,
                              scale: 1.0,
                              alignment: Alignment.center),
                        ),
                        const SizedBox(height: 15),
                        Text(names[index],
                            style: const TextStyle(
                                fontSize: 16, color: Colors.black),
                            textAlign: TextAlign.center),
                      ],
                    ),
                  ),
                ),
              ),
            ),
          ],
        ),
      ),
      bottomNavigationBar: BottomNavigationBarWidget(),
    );
  }
}

New contributor

Hloo is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật