繁体   English   中英

flutter 错误,相关的导致错误的小部件是 Scaffold

[英]flutter error , The relevant error-causing widget was Scaffold

我的代码运行良好,在我试图将我的代码链接到 Firestore 之后,突然出现了这个错误,我仍然无法解决。

════════ 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,
      ),
    );
  }
}
~~~!

您只需运行 flutter clean 然后运行 flutter pub get 命令并重新运行您的项目。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM