Search code examples
androidflutterdart

"Too many positional arguments: 2 excepted, but 3 found. try removing the extra arguments" . please help me:(


body:Container(
        //child: IndexedStack(
          //index: _selectedIndex,
          //children: _items
        //)//_items.elementAt(_index),
        height: MediaQuery.of(context).size.height*0.25,
        margin: EdgeInsets.all(20),
        alignment: Alignment.topCenter,
        child: IndexedStack(
          index: _selectedIndex,
          children: [
            ElevatedButton(
              style: ElevatedButton.styleFrom(
                minimumSize: const
                Size.fromHeight(50)
              ),
              child: Text('SUBUH'),
              onPressed: (){
                Navigator.push(context,
                MaterialPageRoute(
                  builder: (context) => halamansubuh(
                  )
                  ),
                  ElevatedButton(
                    style: ElevatedButton.styleFrom(
                      minimumSize: const
                      Size.fromHeight(100)
                  ),
                    child: Text('ZUHUR'),
                    onPressed: (){
                      Navigator.push(context,
                      MaterialPageRoute(
                        builder: (context) => halamanzuhur(title: 'halamanzuhur', desc: 'halamanzuhur',
                        
                        )
                        ));
                    }
                  ),
                  );
              }
            )

Solution

  • Replace your code with this code

     Container(
        //child: IndexedStack(
          //index: _selectedIndex,
          //children: _items
        //)//_items.elementAt(_index),
        height: MediaQuery.of(context).size.height*0.25,
        margin: EdgeInsets.all(20),
        alignment: Alignment.topCenter,
        child: IndexedStack(
          index: _selectedIndex,
          children: [
            ElevatedButton(
              style: ElevatedButton.styleFrom(
                minimumSize: const
                Size.fromHeight(50)
              ),
              child: Text('SUBUH'),
              onPressed: (){
                Navigator.push(context,
                MaterialPageRoute(
                  builder: (context) => halamansubuh(
                  )
                  ),);}),
            
                  ElevatedButton(
                    style: ElevatedButton.styleFrom(
                      minimumSize: const
                      Size.fromHeight(100)
                  ),
                    child: Text('ZUHUR'),
                    onPressed: (){
                      Navigator.push(context,
                      MaterialPageRoute(
                        builder: (context) => halamanzuhur(title: 'halamanzuhur', desc: 'halamanzuhur',
                        
                        )
                        ));
                    }
                  ),
                  
            ]
            ));