1
0
mirror of https://github.com/nisrulz/flutter-examples.git synced 2026-08-25 09:13:00 +00:00

chore: modernize Flutter examples — null safety, latest APIs, Kotlin DSL Gradle (#148)

* 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
This commit is contained in:
Nishant Srivastava
2026-08-17 13:58:51 +02:00
committed by GitHub
parent 80fe9bed92
commit 8745f7cf5a
2600 changed files with 9278 additions and 58100 deletions

View File

@@ -1,62 +0,0 @@
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'com.google.gms.google-services'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion 30
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "github.nisrulz.firebase_google_authentication"
minSdkVersion 21
targetSdkVersion 30
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation platform('com.google.firebase:firebase-bom:28.4.2')
implementation 'com.google.firebase:firebase-analytics'
}

View File

@@ -0,0 +1,43 @@
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id("dev.flutter.flutter-gradle-plugin")
}
android {
namespace = "github.nisrulz.firebase_google_authentication"
compileSdk = flutter.compileSdkVersion
ndkVersion = flutter.ndkVersion
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
defaultConfig {
applicationId = "github.nisrulz.firebase_google_authentication"
minSdk = flutter.minSdkVersion
targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode
versionName = flutter.versionName
}
buildTypes {
release {
signingConfig = signingConfigs.getByName("debug")
}
}
}
kotlin {
compilerOptions {
jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17
}
}
apply(plugin = "com.google.gms.google-services")
flutter {
source = "../.."
}

View File

@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="github.nisrulz.firebase_google_authentication">
>
<application
android:label="firebase_google_authentication"
android:icon="@mipmap/ic_launcher">

View File

@@ -1,30 +0,0 @@
buildscript {
ext.kotlin_version = '1.3.50'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.3.10'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}

View File

@@ -0,0 +1,24 @@
allprojects {
repositories {
google()
mavenCentral()
}
}
val newBuildDir: Directory =
rootProject.layout.buildDirectory
.dir("../../build")
.get()
rootProject.layout.buildDirectory.value(newBuildDir)
subprojects {
val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name)
project.layout.buildDirectory.value(newSubprojectBuildDir)
}
subprojects {
project.evaluationDependsOn(":app")
}
tasks.register<Delete>("clean") {
delete(rootProject.layout.buildDirectory)
}

View File

@@ -1,3 +1,4 @@
org.gradle.jvmargs=-Xmx1024M
org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError
android.useAndroidX=true
android.enableJetifier=true
android.newDsl=false
android.builtInKotlin=false

View File

@@ -1,7 +1,9 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.7.0-bin.zip
networkTimeout=10000
retries=0
retryBackOffMs=500
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@@ -1,11 +0,0 @@
include ':app'
def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
def properties = new Properties()
assert localPropertiesFile.exists()
localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
def flutterSdkPath = properties.getProperty("flutter.sdk")
assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"

View File

@@ -0,0 +1,27 @@
pluginManagement {
val flutterSdkPath =
run {
val properties = java.util.Properties()
file("local.properties").inputStream().use { properties.load(it) }
val flutterSdkPath = properties.getProperty("flutter.sdk")
require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" }
flutterSdkPath
}
includeBuild("$flutterSdkPath/packages/flutter_tools/gradle")
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
plugins {
id("dev.flutter.flutter-plugin-loader") version "1.0.0"
id("com.android.application") version "9.1.0" apply false
id("org.jetbrains.kotlin.android") version "2.2.20" apply false
id("com.google.gms.google-services") version "4.4.2" apply false
}
include(":app")

View File

@@ -1,9 +1,6 @@
import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_google_authentication/Screens/InfoPage.dart';
import 'package:firebase_google_authentication/Screens/SignUpPage.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:google_fonts/google_fonts.dart';
@@ -21,20 +18,22 @@ class _HomePageState extends State<HomePage> {
final Size size = MediaQuery.of(context).size;
return Scaffold(
body: StreamBuilder(
stream: FirebaseAuth.instance.authStateChanges(),
builder: (context, snapshot) {
if(snapshot.connectionState ==ConnectionState.waiting){
return Center(child: CircularProgressIndicator(),);
}
else if(snapshot.hasError){
return Center(child: Text('An error Occured!!'),);
}else if(snapshot.hasData){
return InfoPage();
}else {
return home(size, context);
}
}
),
stream: FirebaseAuth.instance.authStateChanges(),
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.waiting) {
return Center(
child: CircularProgressIndicator(),
);
} else if (snapshot.hasError) {
return Center(
child: Text('An error Occured!!'),
);
} else if (snapshot.hasData) {
return InfoPage();
} else {
return home(size, context);
}
}),
);
}
@@ -42,64 +41,76 @@ class _HomePageState extends State<HomePage> {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('Welcome!',
Text(
'Welcome!',
style: GoogleFonts.lora(
fontSize: 36,
fontWeight: FontWeight.w500,
),
),
SizedBox(height: 30,),
SvgPicture.asset(
'assets/login.svg',
width: size.width*0.8,
height: size.height*0.3,
SizedBox(
height: 30,
),
SvgPicture.asset(
'assets/login.svg',
width: size.width * 0.8,
height: size.height * 0.3,
),
SizedBox(
height: 60,
),
SizedBox(height: 60,),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Container(
width: size.width*0.8,
width: size.width * 0.8,
child: ClipRRect(
borderRadius: BorderRadius.circular(29),
child: FlatButton(
padding: EdgeInsets.symmetric(vertical: 15,horizontal: 40),
onPressed: (){
Navigator.push(context, MaterialPageRoute(builder: (context)=>SignUpPage(true)));
child: TextButton(
style: TextButton.styleFrom(
padding:
EdgeInsets.symmetric(vertical: 15, horizontal: 40),
backgroundColor: Color(0xFF6F35A5)),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SignUpPage(true)));
},
child: Text('Login',
child: Text(
'Login',
style: GoogleFonts.alice(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 20
),
fontSize: 20),
),
color: Color(0xFF6F35A5),
),
),
),
],
),
SizedBox(height: 15,),
SizedBox(
height: 15,
),
Container(
width: size.width*0.8,
width: size.width * 0.8,
child: ClipRRect(
borderRadius: BorderRadius.circular(29),
child: FlatButton(
padding: EdgeInsets.symmetric(vertical: 15,horizontal: 40),
onPressed: (){
child: TextButton(
style: TextButton.styleFrom(
padding: EdgeInsets.symmetric(vertical: 15, horizontal: 40),
backgroundColor: Color(0xFFF1E6FF)),
onPressed: () {
Navigator.push(context,
MaterialPageRoute(builder: (context)=> SignUpPage(false))
);
MaterialPageRoute(builder: (context) => SignUpPage(false)));
},
child: Text('SignUp',
child: Text(
'SignUp',
style: GoogleFonts.alice(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 20
),
fontSize: 20),
),
color: Color(0xFFF1E6FF),
),
),
),

View File

@@ -22,13 +22,15 @@ class _InfoPageState extends State<InfoPage> {
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
FlatButton(onPressed: (){
final provider = Provider.of<GoogleSignInProvider>(
context,
listen: false);
provider.googleLogout();
},
child: Text('Logout',
TextButton(
onPressed: () {
final provider = Provider.of<GoogleSignInProvider>(
context,
listen: false);
provider.googleLogout();
},
child: Text(
'Logout',
style: TextStyle(
color: Colors.blue,
fontSize: 16,
@@ -36,23 +38,23 @@ class _InfoPageState extends State<InfoPage> {
)),
],
),
SizedBox(height: 200,),
SizedBox(
height: 200,
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
//crossAxisAlignment: CrossAxisAlignment.center,
children: [
CircleAvatar(
radius: 40,
backgroundImage: NetworkImage(
user!.photoURL??'https://cdn.pixabay.com/photo/2015/10/05/22/37/blank-profile-picture-973460_1280.png'
),
backgroundImage: NetworkImage(user!.photoURL ??
'https://cdn.pixabay.com/photo/2015/10/05/22/37/blank-profile-picture-973460_1280.png'),
),
SizedBox(height: 15,),
Text(user!.email??'',
style: TextStyle(
fontSize: 18,
fontWeight: FontWeight.w500
),
SizedBox(
height: 15,
),
Text(
user!.email ?? '',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.w500),
),
],
)

View File

@@ -7,7 +7,6 @@ import 'package:google_fonts/google_fonts.dart';
import 'package:provider/provider.dart';
class SignUpPage extends StatefulWidget {
//const SignUpPage({Key? key}) : super(key: key);
bool isLogin;
SignUpPage(this.isLogin);
@override
@@ -35,6 +34,7 @@ class _SignUpPageState extends State<SignUpPage> {
);
ScaffoldMessenger.of(context).showSnackBar(snackBar);
}
@override
Widget build(BuildContext context) {
final Size size = MediaQuery.of(context).size;
@@ -51,7 +51,7 @@ class _SignUpPageState extends State<SignUpPage> {
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(
(isLogin)?'Login':'SignUp',
(isLogin) ? 'Login' : 'SignUp',
style: GoogleFonts.alice(
fontWeight: FontWeight.bold,
fontSize: 29,
@@ -61,7 +61,7 @@ class _SignUpPageState extends State<SignUpPage> {
height: 20,
),
SvgPicture.asset(
(isLogin)?'assets/signup.svg':'assets/signup.svg',
(isLogin) ? 'assets/signup.svg' : 'assets/signup.svg',
width: size.width * 0.5,
height: size.height * 0.3,
),
@@ -110,27 +110,27 @@ class _SignUpPageState extends State<SignUpPage> {
),
suffixIcon: showPassword
? IconButton(
icon: Icon(
Icons.visibility_off,
color: Color(0xFF6F35A5),
),
onPressed: () {
setState(() {
showPassword = !showPassword;
});
},
)
icon: Icon(
Icons.visibility_off,
color: Color(0xFF6F35A5),
),
onPressed: () {
setState(() {
showPassword = !showPassword;
});
},
)
: IconButton(
icon: Icon(
Icons.visibility,
color: Color(0xFF6F35A5),
),
onPressed: () {
setState(() {
showPassword = !showPassword;
});
},
)),
icon: Icon(
Icons.visibility,
color: Color(0xFF6F35A5),
),
onPressed: () {
setState(() {
showPassword = !showPassword;
});
},
)),
),
),
SizedBox(
@@ -140,24 +140,26 @@ class _SignUpPageState extends State<SignUpPage> {
width: size.width * 0.8,
child: ClipRRect(
borderRadius: BorderRadius.circular(29),
child: FlatButton(
padding:
EdgeInsets.symmetric(vertical: 15, horizontal: 40),
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);
!(isLogin)
? signUpClicked(_email, _password, context)
: loginClicked(_email, _password, context);
},
child: Text(
(isLogin)?'Login':'SignUp',
(isLogin) ? 'Login' : 'SignUp',
style: GoogleFonts.alata(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 20),
),
color: Color(0xFF6F35A5),
),
),
),
@@ -168,9 +170,12 @@ class _SignUpPageState extends State<SignUpPage> {
width: size.width * 0.81,
child: ClipRRect(
borderRadius: BorderRadius.circular(29),
child: FlatButton.icon(
padding:
EdgeInsets.symmetric(vertical: 15, horizontal: 40),
child: TextButton.icon(
style: TextButton.styleFrom(
padding: EdgeInsets.symmetric(
vertical: 15, horizontal: 40),
backgroundColor: Color(0xFF6F35A5),
),
onPressed: () {
final provider = Provider.of<GoogleSignInProvider>(
context,
@@ -187,13 +192,14 @@ class _SignUpPageState extends State<SignUpPage> {
color: Colors.white,
),
label: Text(
(isLogin)?'Login with Google':'SignUp with Google',
(isLogin)
? 'Login with Google'
: 'SignUp with Google',
style: GoogleFonts.alata(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 20),
),
color: Color(0xFF6F35A5),
),
),
),
@@ -201,7 +207,7 @@ class _SignUpPageState extends State<SignUpPage> {
height: 20,
),
GestureDetector(
onTap: (){
onTap: () {
setState(() {
isLogin = !isLogin;
});
@@ -210,13 +216,15 @@ class _SignUpPageState extends State<SignUpPage> {
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
(isLogin)?'Don\'t have an account?':'Already have an account?',
(isLogin)
? 'Don\'t have an account?'
: 'Already have an account?',
style: GoogleFonts.lato(
color: Color(0xFF6F35A5),
),
),
Text(
(isLogin)?'SignUp':'SignIn',
(isLogin) ? 'SignUp' : 'SignIn',
style: GoogleFonts.lato(
fontWeight: FontWeight.bold,
color: Color(0xFF6F35A5),
@@ -236,16 +244,13 @@ class _SignUpPageState extends State<SignUpPage> {
signUpClicked(String _email, String _password, BuildContext context) {
FirebaseAuth.instance
.createUserWithEmailAndPassword(
email: _email, password: _password)
.createUserWithEmailAndPassword(email: _email, password: _password)
.then((value) {
setState(() {
loggingIn = true;
});
Future.delayed(
Duration(seconds: 1, milliseconds: 50), (){
Navigator.popUntil(
context, (route) => route.isFirst);
Future.delayed(Duration(seconds: 1, milliseconds: 50), () {
Navigator.popUntil(context, (route) => route.isFirst);
});
}).catchError((e) {
showSnackBar();
@@ -253,15 +258,16 @@ class _SignUpPageState extends State<SignUpPage> {
}
bool loginClicked(String _email, String _password, BuildContext context) {
FirebaseAuth.instance.signInWithEmailAndPassword(
email: _email, password: _password).then((value){
FirebaseAuth.instance
.signInWithEmailAndPassword(email: _email, password: _password)
.then((value) {
setState(() {
loggingIn = true;
});
Future.delayed(Duration(seconds: 1,milliseconds: 50),(){
Future.delayed(Duration(seconds: 1, milliseconds: 50), () {
Navigator.pop(context);
});
}).catchError((e){
}).catchError((e) {
showSnackBar();
});
return loggingIn;

View File

@@ -2,10 +2,8 @@ import 'package:firebase_auth/firebase_auth.dart';
import 'package:flutter/cupertino.dart';
import 'package:google_sign_in/google_sign_in.dart';
class GoogleSignInProvider extends ChangeNotifier{
final googleSignIn = GoogleSignIn();
class GoogleSignInProvider extends ChangeNotifier {
final googleSignIn = GoogleSignIn.instance;
GoogleSignInAccount? _user;
User? user1;
@@ -13,37 +11,34 @@ class GoogleSignInProvider extends ChangeNotifier{
String? userId;
FirebaseAuth auth = FirebaseAuth.instance;
Future googleLogin()async{
try{
final googleUser = await googleSignIn.signIn();
if(googleUser == null) return;
Future googleLogin() async {
try {
await googleSignIn.initialize();
final googleUser = await googleSignIn.authenticate();
if (googleUser == null) return;
_user = googleUser;
final googleAuth = await googleUser.authentication;
final credentials = GoogleAuthProvider.credential(
accessToken: googleAuth.accessToken,
idToken: googleAuth.idToken,
);
final UserCredential authresult= await FirebaseAuth.instance.signInWithCredential(credentials);
await FirebaseAuth.instance.signInWithCredential(credentials);
notifyListeners();
}catch(e){
} catch (e) {
print(e.toString());
}
}
Future googleLogout()async{
try{
Future googleLogout() async {
try {
print('Logging Out');
await googleSignIn.disconnect();
FirebaseAuth.instance.signOut();
}catch(e){
} catch (e) {
FirebaseAuth.instance.signOut();
}
notifyListeners();
}
}
}

View File

@@ -18,23 +18,23 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
environment:
sdk: ">=2.12.0 <3.0.0"
sdk: ">=3.0.0 <4.0.0"
dependencies:
flutter:
sdk: flutter
flutter_svg: ^0.22.0
flutter_svg: ^2.3.0
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
google_fonts: ^2.1.0
font_awesome_flutter: ^9.1.0
provider: ^6.0.1
firebase_auth: ^3.1.3
firebase_core: ^1.7.0
google_sign_in:
change_app_package_name: ^1.0.0
cupertino_icons: ^1.0.9
google_fonts: ^8.2.1
font_awesome_flutter: ^11.0.0
provider: ^6.1.5+1
firebase_auth: ^6.5.7
firebase_core: ^4.13.0
google_sign_in: ^7.2.0
change_app_package_name: ^1.5.0
dev_dependencies: