Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep User Logged In #181

Merged
merged 6 commits into from
Apr 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 40 additions & 12 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
Expand All @@ -6,6 +7,8 @@ import 'package:provider/provider.dart';
import 'package:retro_shopping/helpers/ad_state.dart';
import 'package:retro_shopping/helpers/constants.dart';
import 'package:retro_shopping/helpers/route_page.dart';
import 'package:retro_shopping/views/auth/login_view.dart';
import 'package:retro_shopping/views/home_view.dart';

import 'services/remote_config.dart';

Expand Down Expand Up @@ -45,26 +48,51 @@ class MyApp extends StatelessWidget {
}
},
child: MaterialApp(
builder: (BuildContext context, Widget child) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You removed this configuration also, pull the code again and rebase your code.

return ScrollConfiguration(
behavior: CustomScrollBehavior(),
child: child,
);
},
builder: (BuildContext context, Widget child) {
return ScrollConfiguration(
behavior: CustomScrollBehavior(),
child: child,
);
},
home: StreamBuilder<User>(
stream: FirebaseAuth.instance.authStateChanges(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.active) {
bool isloggedin = snapshot.hasData;
if (isloggedin == true) {
return Home();
}
else {
//print("here");
return LoginScreen();
}
}
else {
return Scaffold(
body: Center(
child: CircularProgressIndicator(),
),
);
}
}
),

title: 'Retro Shopping',
debugShowCheckedModeBanner: false,
theme: ThemeData(
// primarySwatch: Colors.blue,
// primarySwatch: Colors.blue,
scaffoldBackgroundColor: RelicColors.backgroundColor,
visualDensity: VisualDensity.adaptivePlatformDensity,
textTheme:
GoogleFonts.poppinsTextTheme(Theme.of(context).textTheme)),
GoogleFonts.poppinsTextTheme(Theme
.of(context)
.textTheme)),
onGenerateRoute: RoutePage.generateRoute,
initialRoute: RouteConstant.LOGIN_SCREEN,
),
);
}
)
);
}
}


class CustomScrollBehavior extends ScrollBehavior {
@override
Expand Down