Home > database >  I've been trying to create the button to navigate to the second page but somehow the RaisedButt
I've been trying to create the button to navigate to the second page but somehow the RaisedButt

Time:11-19

I have been following the yt video on creating the navigation map button but I don't understand what did I do wrong on RaisedButton line (I put in stars infront and at the back)

import 'package:flutter/material.dart';
import 'package:ionicons/ionicons.dart';
import 'package:avenique/pages/PlanningPaymentScreen.dart';

class RootApp extends StatelessWidget {
  RootApp({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        leading: IconButton(
            onPressed: () {
              print("menu pressed");
            },
            icon: Icon(Icons.menu)),
        title: Text("PlanningPage"),
        actions: <Widget>[
          IconButton(
              onPressed: () {
                print("search pressed");
              },
              icon: Icon(Icons.search)),
        ],
      ),
      body: Center(
     **   child:RaisedButton(  **
            child: Text(
              'Next Screen',
              style: TextStyle(
                color: Color.fromARGB(255, 255, 255, 255),
              ),
              ),
              Color: Color.fromARGB(255, 0, 0, 0),
              onPressed: () {
                Navigator.push(
                  context,
                  MaterialPageRoute(
                      builder: (context) => PlanningPaymentScreen()),
                );
              }),
      ),
    );
  }


}

I expected the code to run smoothly. Thankyou for the help!

CodePudding user response:

Since RaisedButton is deprecated. try using " ElevatedButton " and you will find a function inside then you can push.

onPressed: () {
  Navigator.push(
    context,
    MaterialPageRoute(builder: (context) => SecondRoute()),
  );
}
  • Related