skip to Main Content

class _BottomPart extends StatelessWidget {
const _BottomPart({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return Align(
alignment: Alignment.bottomCenter,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 40.0),
child: Column(

      mainAxisSize: MainAxisSize.min,
      children: [
        const Text(
          'Find The Best Coffee for You',
          style: TextStyle(
              fontSize: 27.0,
              fontWeight: FontWeight.bold,
              color: Colors.white),
        ),
        const SizedBox(height: 30.0),
        Text(
          'Lorem ipsum dolor sit amet, adipiscing elit. '
              'Nullam pulvinar dolor sed enim eleifend efficitur.',
          style: TextStyle(
            fontSize: 15.0,
            color: Colors.white.withOpacity(0.8),
            height: 1.5,
          ),
        ),
        const SizedBox(height: 50.0),
        Align(
          alignment: Alignment.centerRight,
          child: Container(

            height: 85.0,
            width: 85.0,
            decoration: BoxDecoration(
              shape: BoxShape.circle,
              border: Border.all(color: Colors.white, width: 2.0),
            ),
            child: const Icon(
              Icons.chevron_right,
              size: 50.0,
              color: Colors.white,
            ),
          ),
        ),
        const SizedBox(height: 50.0),

      ],
    ),
  ),
);

}
}

2

Answers


  1. The easiest way to do it is (assuming that your home is a named route with / as name):

    Navigator.popUntil(context, ModalRoute.withName('/'));
    
    Login or Signup to reply.
  2. Below is the example of how I go about getting back to the home page and emptying the stack. it is also useful in a disconnection.

    class MyWidget extends StatelessWidget {
      @override
      Widget build(BuildContext context) {
        return TextButton(
          child: const Text('Log out'), // Go to the HomePage 
          onPressed:(){
            // if you use named routes
            Navigator.of(context).pushAndRemoveUntil<void>(
                "/route/to/homepage", (route) => false,
            );
    
            // if you don't use named routes
            Navigator.of(context).popUntil((route) => route.isFirst);
          }
        );
      }
    }
    
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search