Skip to content

Instantly share code, notes, and snippets.

View Shubham-Narkhede's full-sized avatar
🎯
Focusing

Shubham-Narkhede Shubham-Narkhede

🎯
Focusing
View GitHub Profile
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return StreamBuilder(
stream: Connectivity().onConnectivityChanged,
builder: (context, AsyncSnapshot<ConnectivityResult> snapshot) {
return snapshot.data == ConnectivityResult.mobile ||
static Widget buildSignupSigninBtn(var quetion, var pageName, Function function) {
return Padding(padding: EdgeInsets.only(bottom: 0,top: 5),child: GestureDetector(
onTap: () {
function();
},
child: RichText(
text: TextSpan(
children: [
TextSpan(
text: quetion,
Widget _buildSocialBtn(Function onTap, AssetImage logo) {
return GestureDetector(
onTap: onTap,
child: Container(
height: 60.0,
width: 60.0,
decoration: BoxDecoration(
shape: BoxShape.circle,
color: Colors.white,
static Widget buildLoginBtn(var buttonTitle, Function function) {
return Container(
// height: 90,
padding: EdgeInsets.only(right: 40,left: 40,bottom: 15),
width: double.infinity,
child: RaisedButton(
elevation: 5.0,
onPressed: () {
function();
},
MaterialButton(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(40),
),
color: Colors.white,
child: Text('Simple Pop Up'),
onPressed: () async {
await animated_dialog_box.showCustomAlertBox(
// You can change the animation which u=you want to use like
Future googleLogin() async {
final GoogleSignInAccount googleSignInAccount = await googleSignIn.signIn();
final GoogleSignInAuthentication googleSignInAuthentication =
await googleSignInAccount.authentication;
final AuthCredential credential = GoogleAuthProvider.getCredential(
accessToken: googleSignInAuthentication.accessToken,
idToken: googleSignInAuthentication.idToken,
);
void _twitterLogin() async {
String newMessage;
final TwitterLoginResult result = await twitterLogin.authorize();
switch (result.status) {
case TwitterLoginStatus.loggedIn:
newMessage = 'Logged in! username: ${result.session.username}';
break;
case TwitterLoginStatus.cancelledByUser:
Future insertData(var username, var useremail, var userimage, var userauth,
var usersource) async {
var url = "YOUR_INSERT_DATA_API";
final response = await http.post(url, body: {
"username": username,
"useremail": useremail,
"userimage": userimage,
"userauth": userauth,
"usersource": usersource
});
case FacebookLoginStatus.loggedIn:
final FacebookAccessToken accessToken = result.accessToken;
var response = await http.get(
'https://graph.facebook.com/v2.12/me?fields=name,first_name,last_name,email,picture&access_token=${result.accessToken.token}');
var responseData = json.decode(response.body);
insertData(responseData['name'],responseData['email'],responseData['picture']['data']['url'],responseData['id'],"Facebook");
break;
import 'package:flutter/material.dart';
void main() => runApp(new MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(title: 'Flutter Animated Popup', theme: ThemeData(), home: _myApp());
}
}