Friday, March 22, 2019

Google Signin Flutter

import 'package:flutter/material.dart';
import 'package:google_sign_in/google_sign_in.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  GoogleSignIn _googleSignIn = new GoogleSignIn(
    scopes: <String>[
      'profile',
      'email',
      'https://www.googleapis.com/auth/contacts.readonly',
    ],
  );

  Future<void> _handleSignIn() async {
    try {
      await _googleSignIn.signIn();
      print("signed in" + _googleSignIn.currentUser.email);
    } catch (error) {
      print(error);
    }
  }

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: RaisedButton(onPressed: () {
          _handleSignIn();
        }),
      ),
    );
  }
}





--------------------library--------------------

 google_sign_in: ^4.0.1+1

 firebase_auth: ^0.6.6

Tuesday, March 5, 2019

Splash Screen

import 'dart:async';
import 'package:flutter/material.dart';
import 'homeScreen.dart';
import 'MyHome.dart';
import 'account.dart';


void main() {
  runApp(new MaterialApp(
    home: new MyApp(),
    debugShowCheckedModeBanner: false,
    routes: <String, WidgetBuilder>{
      '/HomeScreen': (BuildContext context) => new MyHome()
    },
  ));
}

class MyApp extends StatefulWidget {
  @override
  _SplashScreenState createState() => new _SplashScreenState();
}

class _SplashScreenState extends State<MyApp> {
  startTime() async {
    var _duration = new Duration(seconds: 2);
    return new Timer(_duration, navigationPage);
  }

  void navigationPage() {
    Navigator.of(context).pushReplacementNamed('/HomeScreen');
  }

  @override
  void initState() {
    super.initState();
    startTime();
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
      body: new Container(
        color: Colors.black,
        child: Center(
          child: SingleChildScrollView(
            child: new Container(
              child: new Column(
                children: <Widget>[
                  Text("Urbanvogue",style: TextStyle(fontSize: 40.0,fontStyle: FontStyle.italic,color: Colors.green,),)
                ],
              ),
            ),
          ),
        ),
       /* decoration: new BoxDecoration(
          image: new DecorationImage(
              image: new AssetImage("images/logo.png"), fit: BoxFit.cover),
        ),*/
      ),
    );
  }
}

How to save contact number in flutter

with contacts_service: 0.3.10 https://pub.dev/packages/contacts_service Future < void > contactSave (){ Contact contac...