Skip to content

Commit

Permalink
flutterfire setup and configure
Browse files Browse the repository at this point in the history
  • Loading branch information
chiragtyagi2003 committed Jun 12, 2024
1 parent 4cf97a9 commit 38bc4d3
Show file tree
Hide file tree
Showing 13 changed files with 225 additions and 49 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id "com.android.application"
id "kotlin-android"
id "dev.flutter.flutter-gradle-plugin"
id("com.google.gms.google-services")
id "com.google.gms.google-services"
}

def localProperties = new Properties()
Expand Down Expand Up @@ -46,7 +46,7 @@ android {
applicationId "com.example.firebase_editor_gsoc"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
minSdkVersion flutter.minSdkVersion
minSdkVersion 21
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ pluginManagement {
}
settings.ext.flutterSdkPath = flutterSdkPath()

includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")

includeBuild("${settings.ext.flutterSdkPath}/packages/flutter_tools/gradle")
repositories {
google()
mavenCentral()
Expand All @@ -20,7 +20,7 @@ pluginManagement {
plugins {
id "dev.flutter.flutter-plugin-loader" version "1.0.0"
id "com.android.application" version "7.3.0" apply false
id "org.jetbrains.kotlin.android" version "1.7.10" apply false
id "org.jetbrains.kotlin.android" version "1.9.24" apply false
id 'com.google.gms.google-services' version '4.4.2' apply false
}

Expand Down
1 change: 1 addition & 0 deletions firebase.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"flutter":{"platforms":{"android":{"default":{"projectId":"gsoc-24-3f4d1","appId":"1:211384953661:android:14233d29467afa30317354","fileOutput":"android/app/google-services.json"}},"dart":{"lib/firebase_options.dart":{"projectId":"gsoc-24-3f4d1","configurations":{"android":"1:211384953661:android:14233d29467afa30317354","ios":"1:211384953661:ios:007f4e6da5f618ea317354"}}}}}}
69 changes: 69 additions & 0 deletions lib/firebase_options.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// File generated by FlutterFire CLI.
// ignore_for_file: type=lint
import 'package:firebase_core/firebase_core.dart' show FirebaseOptions;
import 'package:flutter/foundation.dart'
show defaultTargetPlatform, kIsWeb, TargetPlatform;

/// Default [FirebaseOptions] for use with your Firebase apps.
///
/// Example:
/// ```dart
/// import 'firebase_options.dart';
/// // ...
/// await Firebase.initializeApp(
/// options: DefaultFirebaseOptions.currentPlatform,
/// );
/// ```
class DefaultFirebaseOptions {
static FirebaseOptions get currentPlatform {
if (kIsWeb) {
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for web - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
}
switch (defaultTargetPlatform) {
case TargetPlatform.android:
return android;
case TargetPlatform.iOS:
return ios;
case TargetPlatform.macOS:
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for macos - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
case TargetPlatform.windows:
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for windows - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
case TargetPlatform.linux:
throw UnsupportedError(
'DefaultFirebaseOptions have not been configured for linux - '
'you can reconfigure this by running the FlutterFire CLI again.',
);
default:
throw UnsupportedError(
'DefaultFirebaseOptions are not supported for this platform.',
);
}
}

static const FirebaseOptions android = FirebaseOptions(
apiKey: 'AIzaSyAO1F8fTW1EG88fnnTTFRJiKXH4I-MHlbI',
appId: '1:211384953661:android:14233d29467afa30317354',
messagingSenderId: '211384953661',
projectId: 'gsoc-24-3f4d1',
storageBucket: 'gsoc-24-3f4d1.appspot.com',
);

static const FirebaseOptions ios = FirebaseOptions(
apiKey: 'AIzaSyAfe7Be2vESlx3uSGQs_zZ12QWN-EdBgGs',
appId: '1:211384953661:ios:007f4e6da5f618ea317354',
messagingSenderId: '211384953661',
projectId: 'gsoc-24-3f4d1',
storageBucket: 'gsoc-24-3f4d1.appspot.com',
iosClientId: '211384953661-9hkosute6of7qapl18kjacl04m6f14ko.apps.googleusercontent.com',
iosBundleId: 'com.example.firebaseEditorGsoc',
);
}
67 changes: 23 additions & 44 deletions lib/home_screen.dart
Original file line number Diff line number Diff line change
@@ -1,57 +1,36 @@

import 'package:firebase_editor_gsoc/views/circle_widget.dart';
import 'package:firebase_editor_gsoc/views/custom_drawer.dart';
import 'package:firebase_editor_gsoc/views/define_schema.dart';
import 'package:flutter/material.dart';
import 'user_profile.dart';
import 'package:google_sign_in/google_sign_in.dart';


class HomeScreen extends StatelessWidget {
final GoogleSignIn googleSignIn = GoogleSignIn();

void _handleSignOut(BuildContext context) async {
try {
await googleSignIn.signOut();
// Navigate to the sign-in screen after signing out
Navigator.pop(context);
} catch (error) {
print('Error signing out: $error');
// Handle sign-out error
}
}

@override
Widget build(BuildContext context) {
return Scaffold(
drawer: CustomDrawer(),
appBar: AppBar(
title: Text('Home'),
backgroundColor: Theme.of(context).appBarTheme.backgroundColor,
actions: <Widget>[
IconButton(
icon: Icon(Icons.exit_to_app),
onPressed: () => _handleSignOut(context),
),
],
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [

Icon(Icons.handyman),
Text("Under Developement",
style: Theme.of(context).textTheme.displayLarge?.copyWith(
color: Colors.grey,
fontSize: 30.0
)
,)
// ElevatedButton(
// onPressed: () {
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) => UserProfile(),
// ),
// );
// },
// child: Text('Go to User Profile'),
// ),
//
// ElevatedButton(
// onPressed: () {
// Navigator.push(
// context,
// MaterialPageRoute(
// builder: (context) => DefineSchema(),
// ),
// );
// },
// child: Text('Go to Define Schema'),
// ),
],
),
child: Text('Welcome to Home Screen'),
),
);
}
}
}
39 changes: 39 additions & 0 deletions lib/views/sigin.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import 'package:flutter/material.dart';
import 'package:google_sign_in/google_sign_in.dart';
import 'package:firebase_editor_gsoc/home_screen.dart';



class SignInScreen extends StatelessWidget {
final GoogleSignIn googleSignIn = GoogleSignIn();

void _handleSignIn(BuildContext context) async {
try {
print("IN SIGN IN METHOD");
await googleSignIn.signIn();
// Navigate to the next screen or perform other actions after successful sign-in
Navigator.push(
context,
MaterialPageRoute(builder: (context) => HomeScreen()),
);
} catch (error) {
print('Error signing in with Google: $error');
// Handle sign-in error
}
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Sign In'),
),
body: Center(
child: ElevatedButton(
onPressed: () => _handleSignIn(context),
child: Text('Sign in with Google'),
),
),
);
}
}
3 changes: 2 additions & 1 deletion lib/views/starter_screen_3.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// lib/my_screen.dart

import 'package:firebase_editor_gsoc/home_screen.dart';
import 'package:firebase_editor_gsoc/views/sigin.dart';
import 'package:flutter/material.dart';

class StarterScreen3 extends StatelessWidget {
Expand Down Expand Up @@ -61,7 +62,7 @@ class StarterScreen3 extends StatelessWidget {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => HomeScreen(),
builder: (context) => SignInScreen(),
),
);
},
Expand Down
4 changes: 4 additions & 0 deletions macos/Flutter/GeneratedPluginRegistrant.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
import FlutterMacOS
import Foundation

import firebase_auth
import firebase_core
import google_sign_in_ios

func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin"))
FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin"))
FLTGoogleSignInPlugin.register(with: registry.registrar(forPlugin: "FLTGoogleSignInPlugin"))
}
72 changes: 72 additions & 0 deletions pubspec.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
_flutterfire_internals:
dependency: transitive
description:
name: _flutterfire_internals
sha256: "0816f12bbbd9e21f72ea8592b11bce4a628d4e5cb7a81ff9f1eee4f3dc23206e"
url: "https://pub.dev"
source: hosted
version: "1.3.37"
async:
dependency: transitive
description:
Expand Down Expand Up @@ -57,6 +65,54 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.3.1"
firebase_auth:
dependency: "direct main"
description:
name: firebase_auth
sha256: "3af60a78e92567af3d9a5e25d3955f0f6a3f7a33b900724c1c4c336ff5e44200"
url: "https://pub.dev"
source: hosted
version: "5.1.0"
firebase_auth_platform_interface:
dependency: transitive
description:
name: firebase_auth_platform_interface
sha256: "6941c07a1d129a8b834f85b6673d3455f24102b6338346596c26ef3be2c106ce"
url: "https://pub.dev"
source: hosted
version: "7.4.0"
firebase_auth_web:
dependency: transitive
description:
name: firebase_auth_web
sha256: "5c3f6b45dc141cec858c050d6a6f07bdbfab45ab92a68b32be4b08805bdcadaa"
url: "https://pub.dev"
source: hosted
version: "5.12.2"
firebase_core:
dependency: "direct main"
description:
name: firebase_core
sha256: fae4ab4317c2a7afb13d44ef1e3f9f28a630e10016bc5cfe761e8e6a0ed7816a
url: "https://pub.dev"
source: hosted
version: "3.1.0"
firebase_core_platform_interface:
dependency: transitive
description:
name: firebase_core_platform_interface
sha256: "1003a5a03a61fc9a22ef49f37cbcb9e46c86313a7b2e7029b9390cf8c6fc32cb"
url: "https://pub.dev"
source: hosted
version: "5.1.0"
firebase_core_web:
dependency: transitive
description:
name: firebase_core_web
sha256: "6643fe3dbd021e6ccfb751f7882b39df355708afbdeb4130fc50f9305a9d1a3d"
url: "https://pub.dev"
source: hosted
version: "2.17.2"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -80,6 +136,14 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
font_awesome_flutter:
dependency: transitive
description:
name: font_awesome_flutter
sha256: "275ff26905134bcb59417cf60ad979136f1f8257f2f449914b2c3e05bbb4cd6f"
url: "https://pub.dev"
source: hosted
version: "10.7.0"
google_identity_services_web:
dependency: transitive
description:
Expand Down Expand Up @@ -216,6 +280,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.8"
sign_in_button:
dependency: "direct main"
description:
name: sign_in_button
sha256: "977b9b0415d2f3909e642275dfabba7919ba8e111324641b76cae6d1acbd183e"
url: "https://pub.dev"
source: hosted
version: "3.2.0"
sky_engine:
dependency: transitive
description: flutter
Expand Down
3 changes: 3 additions & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ dependencies:
cupertino_icons: ^1.0.6
http: ^1.2.1
google_sign_in: ^6.2.1
firebase_core: ^3.1.0
firebase_auth: ^5.1.0
sign_in_button: ^3.0.0

dev_dependencies:
flutter_test:
Expand Down
6 changes: 6 additions & 0 deletions windows/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@

#include "generated_plugin_registrant.h"

#include <firebase_auth/firebase_auth_plugin_c_api.h>
#include <firebase_core/firebase_core_plugin_c_api.h>

void RegisterPlugins(flutter::PluginRegistry* registry) {
FirebaseAuthPluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FirebaseAuthPluginCApi"));
FirebaseCorePluginCApiRegisterWithRegistrar(
registry->GetRegistrarForPlugin("FirebaseCorePluginCApi"));
}
2 changes: 2 additions & 0 deletions windows/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#

list(APPEND FLUTTER_PLUGIN_LIST
firebase_auth
firebase_core
)

list(APPEND FLUTTER_FFI_PLUGIN_LIST
Expand Down

0 comments on commit 38bc4d3

Please sign in to comment.