0

Excuse me guys, i tryin to build a new page, but with variable "nextcode" in it. so in the new page, it will show nextcode text

                    onTap: () {
                      Navigator.push(
                          context,
                          MaterialPageRoute(
                              builder: (context) => Lemari(nextcode)));
                    },

but in the line "Widget build(String Kode) {" it must be like this "Widget build(BuildContext context) {"

class Lemari extends StatelessWidget {

  @override
   Widget build(String Kode) {
    return Scaffold(
        appBar: AppBar(
           backgroundColor: Colors.blue[900],
           title: Text('this is th next page'),

        ),
         backgroundColor: Colors.white,
         body: Center(
          child: Column(
            children: [
            Container(height: 100, width: 100, color: Colors.red, child: Text('hhe'),),
            ]
          ),
         ),
    );
  }
}

So anyone who can help me ? please :(

Silent Roar
  • 29
  • 1
  • 4

2 Answers2

0

You don't have to change the build method parameters instead you should add a new parameter in the widget and require it

Example const MyPageView({Key? key}) : super(key: key);

Here you can add another parameter. Then inside the class you define that parameter.. so when you make a new MyPageView you will have to pass the newly added parameter

Bye :)

Patrick G.
  • 458
  • 5
  • 7
0

Your code should have a compiler error

In Lemari , you never declare nextcode and constructor also do not have parameter nextcode.

You can try like this, add

class Lemari extends StatelessWidget {
  final String nextcode;
  const Lemari({Key key, this.nextcode}) : super(key: key);

  @override
  Widget build(BuildContext context) {}
}

if your nextcode is String

Sam Chan
  • 1,665
  • 4
  • 14