mirror of
https://github.com/nisrulz/flutter-examples.git
synced 2026-08-25 09:13:00 +00:00
* updates * Update Gradle wrapper script to fetch latest version online and allow --version override * chore(analytics_integration): migrate Gradle build scripts to Kotlin DSL Convert Groovy build files to Kotlin DSL and bump Gradle wrapper. * chore(animation_example): migrate Gradle build scripts to Kotlin DSL Convert Groovy build files to Kotlin DSL. * chore(biometrics): migrate Gradle build scripts to Kotlin DSL Convert Groovy build files to Kotlin DSL. * chore(bmi_calculator): test test body * chore(bottom_sheet): test test body * chore(custom_home_drawer): migrate Gradle build scripts to Kotlin DSL Convert Groovy build files to Kotlin DSL and bump Gradle wrapper. * chore(covid19_mobile_app): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(dropdown_button): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(enabling_splash_screen): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(expense_planner): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(firebase_crash_reporting): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(firebase_google_authentication): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(flutter_date_pickers-master): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(getx_counter_app): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(google_signin): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(grid_layout): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(handling_routes): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(image_editor): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(image_from_network): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(infinite_list): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(load_local_image): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(load_local_json): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(lunch_app): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(navigation_drawer): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(news_memes_app): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(persist_key_value): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(push_notifications): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(save_data_locally_with_sqlite): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(scan_qr_code): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(simple_material_app): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(sliver_app_bar_example): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(stateful_widget): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(stateless_widgets): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(statless_counter_app): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(tic_tac_toe): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(tip_calculator): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(todo_list_using_provider): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(unit_testing): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(using_alert_dialog): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(using_bottom_nav_bar): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(using_custom_fonts): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(using_edittext): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(using_expansionpanel): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(using_firebase_db): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(using_gradient): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(using_http_get): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(using_interactiveviewer): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(using_listview): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(using_listwheelscrollview): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(using_platform_adaptive): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore(using_snackbar): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(using_stepper): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(using_tabs): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(using_theme): remove legacy nested android project Delete the redundant nested android/ project directory from the old layout. Also update pubspec.yaml SDK constraints and dependencies. * chore(view_pdf_file): migrate Gradle build scripts to Kotlin DSL Convert Groovy build.gradle/settings.gradle to Kotlin DSL and bump Gradle wrapper. * chore: ignore .trash directory * chore: remove IDE configs and PR template * chore(infinite_list): remove legacy nested android project * refactor(infinite_list): migrate theme to ColorScheme API * refactor(using_theme): migrate to ColorScheme API * refactor(analytics_integration): migrate Firebase Analytics API * refactor(firebase_google_authentication): migrate Google Sign-In API * refactor(covid19_mobile_app): migrate theme and buttons to current API * refactor(covid19_mobile_app): replace bezier_chart with fl_chart * refactor(image_editor): migrate image plugins and button styles * refactor(scan_qr_code): migrate mobile_scanner API * refactor(lunch_app): migrate to null safety * refactor(todo_list_using_provider): migrate to null safety * refactor(unit_testing): migrate to null safety * refactor(using_firebase_db): migrate Firebase Database API * fix(update_gradle_wrapper): edit gradle-wrapper.properties directly * refactor(push_notifications): migrate Firebase Messaging API * refactor(using_http_get): migrate to null safety * refactor(using_listview): migrate to null safety * refactor(using_listwheelscrollview): migrate to null safety * refactor(view_pdf_file): migrate to null safety * refactor(bottom_sheet): migrate to null safety * refactor(stateless_widgets): migrate to null safety * chore: regenerate Gradle wrapper * refactor: move maintenance scripts to Makefile * chore: remove generated and IDE files * fix: migrate image_editor to current plugins * fix: migrate news_memes_app share to share_plus * fix: migrate view_pdf_file to syncfusion pdf viewer * fix: update deprecated APIs * style: remove commented-out code
276 lines
10 KiB
Dart
276 lines
10 KiB
Dart
import 'package:firebase_auth/firebase_auth.dart';
|
|
import 'package:firebase_google_authentication/Services/google_auth.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
import 'package:font_awesome_flutter/font_awesome_flutter.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
class SignUpPage extends StatefulWidget {
|
|
bool isLogin;
|
|
SignUpPage(this.isLogin);
|
|
@override
|
|
_SignUpPageState createState() => _SignUpPageState(isLogin);
|
|
}
|
|
|
|
class _SignUpPageState extends State<SignUpPage> {
|
|
bool isLogin;
|
|
_SignUpPageState(this.isLogin);
|
|
|
|
bool loggingIn = false;
|
|
TextEditingController email = new TextEditingController();
|
|
TextEditingController password = new TextEditingController();
|
|
bool showPassword = false;
|
|
|
|
void showSnackBar() {
|
|
final snackBar = new SnackBar(
|
|
content: Text('Invalid Credentials!'),
|
|
backgroundColor: Colors.red,
|
|
padding: EdgeInsets.symmetric(horizontal: 10),
|
|
behavior: SnackBarBehavior.floating,
|
|
shape: RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(14),
|
|
),
|
|
);
|
|
ScaffoldMessenger.of(context).showSnackBar(snackBar);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final Size size = MediaQuery.of(context).size;
|
|
return Scaffold(
|
|
body: SingleChildScrollView(
|
|
child: Container(
|
|
height: size.height,
|
|
width: double.infinity,
|
|
child: Stack(
|
|
alignment: Alignment.center,
|
|
children: [
|
|
Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
crossAxisAlignment: CrossAxisAlignment.center,
|
|
children: [
|
|
Text(
|
|
(isLogin) ? 'Login' : 'SignUp',
|
|
style: GoogleFonts.alice(
|
|
fontWeight: FontWeight.bold,
|
|
fontSize: 29,
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 20,
|
|
),
|
|
SvgPicture.asset(
|
|
(isLogin) ? 'assets/signup.svg' : 'assets/signup.svg',
|
|
width: size.width * 0.5,
|
|
height: size.height * 0.3,
|
|
),
|
|
SizedBox(
|
|
height: 25,
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.only(left: 30, right: 30),
|
|
child: TextField(
|
|
controller: email,
|
|
keyboardType: TextInputType.emailAddress,
|
|
decoration: InputDecoration(
|
|
border: OutlineInputBorder(
|
|
borderSide: BorderSide.none,
|
|
borderRadius: BorderRadius.circular(29),
|
|
),
|
|
hintText: 'Your Email',
|
|
filled: true,
|
|
fillColor: Color(0xFFF1E6FF),
|
|
prefixIcon: Icon(
|
|
Icons.person,
|
|
color: Color(0xFF6F35A5),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 15,
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.only(left: 30, right: 30),
|
|
child: TextField(
|
|
controller: password,
|
|
obscureText: !showPassword,
|
|
decoration: InputDecoration(
|
|
border: OutlineInputBorder(
|
|
borderSide: BorderSide.none,
|
|
borderRadius: BorderRadius.circular(29),
|
|
),
|
|
hintText: 'Password',
|
|
filled: true,
|
|
fillColor: Color(0xFFF1E6FF),
|
|
prefixIcon: Icon(
|
|
Icons.lock,
|
|
color: Color(0xFF6F35A5),
|
|
),
|
|
suffixIcon: showPassword
|
|
? IconButton(
|
|
icon: Icon(
|
|
Icons.visibility_off,
|
|
color: Color(0xFF6F35A5),
|
|
),
|
|
onPressed: () {
|
|
setState(() {
|
|
showPassword = !showPassword;
|
|
});
|
|
},
|
|
)
|
|
: IconButton(
|
|
icon: Icon(
|
|
Icons.visibility,
|
|
color: Color(0xFF6F35A5),
|
|
),
|
|
onPressed: () {
|
|
setState(() {
|
|
showPassword = !showPassword;
|
|
});
|
|
},
|
|
)),
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 30,
|
|
),
|
|
Container(
|
|
width: size.width * 0.8,
|
|
child: ClipRRect(
|
|
borderRadius: BorderRadius.circular(29),
|
|
child: TextButton(
|
|
style: TextButton.styleFrom(
|
|
padding: EdgeInsets.symmetric(
|
|
vertical: 15, horizontal: 40),
|
|
backgroundColor: Color(0xFF6F35A5),
|
|
),
|
|
onPressed: () {
|
|
String _email = email.text;
|
|
String _password = password.text;
|
|
!(isLogin)
|
|
? signUpClicked(_email, _password, context)
|
|
: loginClicked(_email, _password, context);
|
|
},
|
|
child: Text(
|
|
(isLogin) ? 'Login' : 'SignUp',
|
|
style: GoogleFonts.alata(
|
|
color: Colors.white,
|
|
fontWeight: FontWeight.bold,
|
|
fontSize: 20),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 18,
|
|
),
|
|
Container(
|
|
width: size.width * 0.81,
|
|
child: ClipRRect(
|
|
borderRadius: BorderRadius.circular(29),
|
|
child: TextButton.icon(
|
|
style: TextButton.styleFrom(
|
|
padding: EdgeInsets.symmetric(
|
|
vertical: 15, horizontal: 40),
|
|
backgroundColor: Color(0xFF6F35A5),
|
|
),
|
|
onPressed: () {
|
|
final provider = Provider.of<GoogleSignInProvider>(
|
|
context,
|
|
listen: false);
|
|
provider.googleLogin().then((value) {
|
|
Navigator.popUntil(
|
|
context, (route) => route.isFirst);
|
|
}).catchError((onError) {
|
|
showSnackBar();
|
|
});
|
|
},
|
|
icon: FaIcon(
|
|
FontAwesomeIcons.google,
|
|
color: Colors.white,
|
|
),
|
|
label: Text(
|
|
(isLogin)
|
|
? 'Login with Google'
|
|
: 'SignUp with Google',
|
|
style: GoogleFonts.alata(
|
|
color: Colors.white,
|
|
fontWeight: FontWeight.bold,
|
|
fontSize: 20),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
SizedBox(
|
|
height: 20,
|
|
),
|
|
GestureDetector(
|
|
onTap: () {
|
|
setState(() {
|
|
isLogin = !isLogin;
|
|
});
|
|
},
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Text(
|
|
(isLogin)
|
|
? 'Don\'t have an account?'
|
|
: 'Already have an account?',
|
|
style: GoogleFonts.lato(
|
|
color: Color(0xFF6F35A5),
|
|
),
|
|
),
|
|
Text(
|
|
(isLogin) ? 'SignUp' : 'SignIn',
|
|
style: GoogleFonts.lato(
|
|
fontWeight: FontWeight.bold,
|
|
color: Color(0xFF6F35A5),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
)
|
|
],
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
signUpClicked(String _email, String _password, BuildContext context) {
|
|
FirebaseAuth.instance
|
|
.createUserWithEmailAndPassword(email: _email, password: _password)
|
|
.then((value) {
|
|
setState(() {
|
|
loggingIn = true;
|
|
});
|
|
Future.delayed(Duration(seconds: 1, milliseconds: 50), () {
|
|
Navigator.popUntil(context, (route) => route.isFirst);
|
|
});
|
|
}).catchError((e) {
|
|
showSnackBar();
|
|
});
|
|
}
|
|
|
|
bool loginClicked(String _email, String _password, BuildContext context) {
|
|
FirebaseAuth.instance
|
|
.signInWithEmailAndPassword(email: _email, password: _password)
|
|
.then((value) {
|
|
setState(() {
|
|
loggingIn = true;
|
|
});
|
|
Future.delayed(Duration(seconds: 1, milliseconds: 50), () {
|
|
Navigator.pop(context);
|
|
});
|
|
}).catchError((e) {
|
|
showSnackBar();
|
|
});
|
|
return loggingIn;
|
|
}
|
|
}
|