Home > other >  elided 5 frames from class _AssertionError, class _RawReceivePortImpl, class _Timer, and dart:async-
elided 5 frames from class _AssertionError, class _RawReceivePortImpl, class _Timer, and dart:async-

Time:02-01

when I run the project, this error happens and cannot display the app's interface:

The following StackOverflowError was thrown building HomePage(state: _HomePageState#9830f): Stack Overflow

The relevant error-causing widget was HomePage lib\telas\homepage.dart:54 (elided 5 frames from class _AssertionError, class _RawReceivePortImpl, class _Timer, and dart:async-patch)

The homepage code:

void main() => runApp(HomePage());

class HomePage extends StatefulWidget {
  @override
  _HomePageState createState() => _HomePageState();
  
  static elementAt(int opcaoselecionada) {}
}

class _HomePageState extends State<HomePage> {
  int _currentIndex = 0;

   @override
  Widget build(BuildContext context) {
    return Scaffold(
      
      bottomNavigationBar: BottomNavigationBar(
        type: BottomNavigationBarType.fixed,
        currentIndex: _currentIndex,
        onTap: (value) {
                  setState(() => _currentIndex = value);
        },
        backgroundColor: Color.fromARGB(255, 101, 190, 153),
        fixedColor: Colors.white,
        items: [
          BottomNavigationBarItem(
              icon: Icon(Icons.house_outlined),
              label: "inicial",
          ),
          BottomNavigationBarItem(
              icon: Icon(Icons.add),
              label: "Menu",
          ),
          BottomNavigationBarItem(
              icon: Icon(Icons.auto_graph),
              label: "graficos",
          ),
        ],
     

CodePudding user response:

try:

void main() => runApp(MaterialApp(home: HomePage()));

I think you are just missing wrapping your entire app with a MaterialApp. Normally your home widget would have MaterialApp in it which handles routing and all sorts of other things, but is the base widget for an app

  • Related