Whenever user try to signup a new account to app it shows login screen then goes to home screen in flutter?

26 Views Asked by At

I'm using the following code for signin up. But the problem is after successfully signing in When anyone tries to sign up for the app, it redirects them back to the sign-in page. Please tell me how to solve this problem. I would have to close the app and open it back up for it to work.

Here is the code

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_e_commerce_app/Config/size_config.dart';
import 'package:flutter_e_commerce_app/Constants/colors.dart';
import 'package:flutter_e_commerce_app/Providers/user.dart';
import 'package:flutter_e_commerce_app/Screens/Auth/login/login_screen.dart';

import 'components/signup_form.dart';

class SignupScreen extends StatelessWidget {
  static const routeName = '/signup-form-screen';
  const SignupScreen({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: AppColors.antiFlashWhite,
      body: SafeArea(
        child: SingleChildScrollView(
          // physics: const BouncingScrollPhysics(),
          padding: EdgeInsets.only(
            top: getProportionateScreenHeight(0.037),
            // bottom: getProportionateScreenHeight(0.054), //44.h,
           left: getProportionateScreenWidth(0.072),
        right: getProportionateScreenWidth(0.058),
      ),
      child: Container(
        height: getProportionateScreenHeight(0.869),
        width: getProportionateScreenWidth(0.87),
        decoration: BoxDecoration(
          color: AppColors.white,
          borderRadius: BorderRadius.circular(
            getProportionateScreenHeight(0.0123),
          ),
          boxShadow: [
            BoxShadow(
              color: Colors.grey.withOpacity(0.2),
              spreadRadius: 5,
              blurRadius: 10,
              offset: Offset(1, 0),
            ),
          ],
        ), //326.w,
        padding: EdgeInsets.only(
          top: getProportionateScreenHeight(0.052), //41.h, 0.0256
          left: getProportionateScreenWidth(0.093), //35.w,
          right: getProportionateScreenWidth(0.093), //35.w,
        ),
        child: Stack(
          clipBehavior: Clip.none,
          children: [
            Positioned(
              top: -getProportionateScreenHeight(0.05),
              left: -getProportionateScreenWidth(0.09),
              child: IconButton(
                onPressed: () {
                  Navigator.of(context).pushReplacementNamed(
                    LoginScreen.routeName,
                  );
                },
                icon: Icon(
                  CupertinoIcons.back,
                  color: Colors.white,
                ),
              ),
            ),
            Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              mainAxisAlignment: MainAxisAlignment.start,
              // mainAxisSize: MainAxisSize.max,
              children: [
                Text(
                  'Hi!',
                  style: Theme.of(context).textTheme.headline2,
                ),
                SizedBox(
                  height: getProportionateScreenHeight(0.017), //14.h,
                ),
                Align(
                  // alignment: Alignment.center,
                  child: Text(
                    'Create a new account',
                    style: Theme.of(context).textTheme.bodyText1!.copyWith(
                      fontSize: 16,
                    ),
                  ),
                ),
                SizedBox(
                  height: getProportionateScreenHeight(0.048), //20.h,
                ),
                SignupForm(),
                SizedBox(
                  height: getProportionateScreenHeight(0.056), //20.h,
                ),
                Row(
                  mainAxisAlignment: MainAxisAlignment.start,
                  children: [
                    Text(
                      'Already have an account? ',
                      style:
                      Theme.of(context).textTheme.bodyText1!.copyWith(
                        fontSize: 10,
                        // fontWeight: FontWeight.w600,
                      ),
                    ),
                    InkWell(
                      onTap: () {

                        Navigator.of(context).popAndPushNamed(
                          LoginScreen.routeName,
                        );
                      },
                      splashColor: Colors.transparent,
                      child: Text(
                        'Sign In',
                        style:
                        Theme.of(context).textTheme.bodyMedium!.copyWith(
                          fontSize: 10,
                          // fontWeight: FontWeight.bold,
                        ),
                      ),
                    ),
                  ],
                ),
              ],
            ),
          ],
        ),
      ),
    ),
     ),
   );
   }
   }
0

There are 0 best solutions below