Home > Software design >  flutter error , The relevant error-causing widget was Scaffold
flutter error , The relevant error-causing widget was Scaffold

Time:11-19

My code was working perfectly and after I was trying to link my code to the Firestore suddenly this error appeared I still can't solve .

════════ Exception caught by rendering library ═════════════════════════════════

Each child must be laid out exactly once.
The relevant error-causing widget was
Scaffold    
lib\pages\nav.dart:26
import 'package:MeeM/pages/notification.dart';
import 'package:MeeM/pages/user.dart';
import 'package:flutter/material.dart';
import 'package:MeeM/pages/Home.dart';
import 'package:MeeM/pages/search.dart';
import 'package:MeeM/add/add.dart';
import 'package:MeeM/profileUI/profile.dart';
import 'package:MeeM/pages/signup_page.dart';

// ignore: camel_case_types
class nav extends StatefulWidget {
  @override
  _navState createState() => _navState();
}

// ignore: camel_case_types
class _navState extends State<nav> {
  int _currentindex = 0;
  List<Widget> _widgeroption = <Widget>[
    Home(currentUser: currentUser),
    search(),
    add(currentUser: currentUser),
    notification(),
    profile(profileId: currentUser?.id),
  ];

  void _onItemTap(int index) {
    setState(() {
      _currentindex = index;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: IndexedStack(
        index: _currentindex,
        children: _widgeroption,
      ),
      bottomNavigationBar: BottomNavigationBar(
        elevation: 0,
        type: BottomNavigationBarType.fixed,
        backgroundColor: Colors.white,
        items: const <BottomNavigationBarItem>[
          BottomNavigationBarItem(
            // ignore: deprecated_member_use
            icon: Icon(
              Icons.home_outlined,
              color: Colors.black,
              size: 30,
            ),
            label: 'home',
          ),
          BottomNavigationBarItem(
            // ignore: deprecated_member_use
            icon: Icon(
              Icons.search,
              color: Colors.black,
              size: 30,
            ),
            label: 'search',
          ),
          BottomNavigationBarItem(
            // ignore: deprecated_member_use
            icon: Icon(
              Icons.add_box_outlined,
              color: Colors.black,
              size: 30,
            ),
            label: 'upload',
          ),
          BottomNavigationBarItem(
            icon: Icon(
              Icons.notifications_none_outlined,
              color: Colors.black,
              size: 30,
            ),
            label: 'feed',
          ),
          BottomNavigationBarItem(
            // ignore: deprecated_member_use
            icon: Icon(
              Icons.person,
              color: Colors.black,
              size: 30,
            ),
            label: 'profile',
          ),
        ],
        showSelectedLabels: false,
        showUnselectedLabels: false,
        currentIndex: _currentindex,
        onTap: _onItemTap,
      ),
    );
  }
}
~~~!

CodePudding user response:

you just have to run flutter clean and then run flutter pub get command and re-run your project.

  • Related