-
-
Save muyiwexy/c144c7dc8f502b64618c654065d20bbf to your computer and use it in GitHub Desktop.
template for a github social login
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:appwrite/appwrite.dart'; | |
import 'package:flutter/services.dart'; | |
import 'package:font_awesome_flutter/font_awesome_flutter.dart'; | |
import 'package:webappgit/app_constants.dart'; | |
void main() { | |
runApp(const MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
const MyApp({Key? key}) : super(key: key); | |
// This widget is the root of your application. | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter Demo', | |
debugShowCheckedModeBanner: false, | |
theme: ThemeData( | |
primarySwatch: Colors.grey, | |
), | |
initialRoute: '/', | |
routes: { | |
'/': (context) => const MyLoginPage(title: 'Login'), | |
'/home': (context) => const MyHomePage(title: 'Home'), | |
}, | |
// home: const MyHomePage(title: 'Flutter Demo Home Page'), | |
); | |
} | |
} | |
class MyLoginPage extends StatefulWidget { | |
const MyLoginPage({Key? key, required this.title}) : super(key: key); | |
final String title; | |
@override | |
State<MyLoginPage> createState() => _MyLoginPageState(); | |
} | |
class _MyLoginPageState extends State<MyLoginPage> { | |
// functionality | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text(widget.title), | |
), | |
body: _buildBody(), | |
); | |
} | |
Widget _buildBody() { | |
return Center( | |
child: _buildStack(), | |
); | |
} | |
Widget _buildStack() { | |
return Stack( | |
alignment: Alignment.center, | |
children: [ | |
_buildIntrinsicHeightContainer(), | |
], | |
); | |
} | |
Widget _buildIntrinsicHeightContainer() { | |
return IntrinsicHeight( | |
child: _buildContainer(), | |
); | |
} | |
Widget _buildContainer() { | |
return Container( | |
padding: const EdgeInsets.all(16), | |
decoration: BoxDecoration( | |
color: Colors.grey[600], | |
borderRadius: BorderRadius.circular(40), | |
boxShadow: [ | |
BoxShadow( | |
blurRadius: 20, | |
offset: const Offset(0, 10), | |
color: Colors.black.withOpacity(.12), | |
) | |
], | |
), | |
child: _buildColumn(), | |
); | |
} | |
Widget _buildColumn() { | |
return Column( | |
children: [ | |
_buildIconContainer(), | |
_buildSizedBox(), | |
_buildSignInButton(), | |
], | |
); | |
} | |
Widget _buildIconContainer() { | |
return Container( | |
decoration: BoxDecoration( | |
borderRadius: BorderRadius.circular(40), | |
boxShadow: [ | |
BoxShadow( | |
blurRadius: 10, | |
offset: const Offset(0, 10), | |
color: Colors.black.withOpacity(.12), | |
) | |
], | |
), | |
child: const Icon( | |
FontAwesomeIcons.github, | |
size: 300, | |
color: Colors.black, | |
), | |
); | |
} | |
Widget _buildSizedBox() { | |
return const SizedBox( | |
height: 20, | |
); | |
} | |
Widget _buildSignInButton() { | |
return ElevatedButton( | |
onPressed: _githubLogin, | |
style: ButtonStyle( | |
backgroundColor: | |
MaterialStateProperty.resolveWith((states) => Colors.black), | |
minimumSize: | |
MaterialStateProperty.resolveWith((states) => const Size(88, 36)), | |
shape: MaterialStateProperty.resolveWith((states) => | |
RoundedRectangleBorder(borderRadius: BorderRadius.circular(8))), | |
), | |
child: const Text("Sign in with Github", | |
style: TextStyle(color: Colors.white)), | |
); | |
} | |
} | |
class MyHomePage extends StatefulWidget { | |
const MyHomePage({super.key, required this.title}); | |
final String title; | |
@override | |
State<MyHomePage> createState() => _MyHomePageState(); | |
} | |
class _MyHomePageState extends State<MyHomePage> { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text(widget.title), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment