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),
        ),*/
      ),
    );
  }
}

Saturday, December 8, 2018

Login Page

class Login extends StatefulWidget{
  @override  _loginUser createState()=>_loginUser();
}
class _loginUser extends State<Login>{
  @override  Widget build(BuildContext context) {
    // TODO: implement build    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: Container(
        decoration: BoxDecoration(
            image: DecorationImage(
                image: AssetImage("images/images.png"), fit: BoxFit.cover)),
        child: Scaffold(
          backgroundColor: Colors.transparent,
          body: Container(
              child: Center(
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    Text(
                      "Login",
                      style: TextStyle(
                          color: Colors.black,
                          fontSize: 30.0,
                          fontWeight: FontWeight.bold),
                    ),
                    Padding(
                      padding: EdgeInsets.only(top: 40.0),
                    ),
                    Padding(
                      padding: EdgeInsets.fromLTRB(22.0, 0.0, 22.0, 10.0),
                      child: TextFormField(
                        textAlign: TextAlign.left,
                        style: TextStyle(
                          color: Colors.black,
                        ),
                        decoration: InputDecoration(
                          prefixIcon: Icon(Icons.email,color: Colors.white,),
                          hintText: 'Email',
                          contentPadding:
                          EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 10.0),
                          border: OutlineInputBorder(
                            borderSide: BorderSide(color: Colors.white),
                          ),
                        ),
                      ),
                    ),
                    Padding(
                      padding: EdgeInsets.fromLTRB(22.0, 0.0, 22.0, 10.0),
                      child: TextFormField(
                        textAlign: TextAlign.left,
                        style: TextStyle(
                          color: Colors.black,
                        ),
                        decoration: InputDecoration(
                          prefixIcon: Icon(Icons.lock_open,color: Colors.white,),
                          hintText: 'Password',
                          contentPadding:
                          EdgeInsets.fromLTRB(10.0, 10.0, 10.0, 10.0),
                          border: OutlineInputBorder(
                            borderSide: BorderSide(color: Colors.grey),
                          ),
                        ),
                      ),
                    ),
                    Padding(
                      padding: EdgeInsets.fromLTRB(22.0, 0.0, 22.0, 22.0),
                      child: Row(
                        children: <Widget>[
                          Expanded(
                            flex: 1,
                            child: ButtonTheme(
                              minWidth: 200.0,
                              height: 40.0,
                              buttonColor: Colors.lightBlue,
                              child: RaisedButton(
                                elevation: 8.0,
                                shape: OutlineInputBorder(
                                  borderSide: BorderSide(color: Colors.lightBlue),
                                  borderRadius: BorderRadius.circular(5.0),
                                ),
                                onPressed: () {
                                  Navigator.push(context, MaterialPageRoute(builder: (context)=>HomePage()));
                                },
                                child: Text(
                                  'Login',
                                  style: TextStyle(
                                      fontSize: 16.0, color: Colors.white),
                                ),
                              ),
                            ),
                          ),
                          Padding(padding: EdgeInsets.fromLTRB(5.0,0.0,5.0,0.0),),
                          Expanded(
                            flex: 1,
                            child: ButtonTheme(
                              minWidth: 200.0,
                              height: 40.0,
                              buttonColor: Colors.orangeAccent,
                              child: RaisedButton(
                                elevation: 8.0,
                                shape: OutlineInputBorder(
                                  borderSide:
                                  BorderSide(color: Colors.orangeAccent),
                                  borderRadius: BorderRadius.circular(5.0),
                                ),
                                onPressed: () {
                                  Navigator.push(context, MaterialPageRoute(builder: (context)=>Register()));
                                },
                                child: Text(
                                  'Register',
                                  style: TextStyle(
                                      fontSize: 16.0, color: Colors.white),
                                ),
                              ),
                            ),
                          ),
                        ],
                      ),
                    ),
                  ],
                ),
              )),
        ),
      ),
    );
  }
}

Simple Form Page Design

class AccountSettingDetail extends StatefulWidget {
  @override  AccountSettingData createState() => AccountSettingData();
}

class AccountSettingData extends State<AccountSettingDetail> {
  @override  Widget build(BuildContext context) {
    // TODO: implement build    return MaterialApp(

      debugShowCheckedModeBanner: false,
      home: Scaffold(
        appBar: AppBar(
          backgroundColor: Colors.orange,
          title: Text(
            'Account Setting',
            style: TextStyle(color: Colors.white),
          ),
          centerTitle: true,
          leading: new IconButton(
              icon: new Icon(Icons.arrow_back_ios),
              onPressed: () {
                Navigator.pop(context, true);
              }),
        ),
        body: SingleChildScrollView(
          child: Container(
            padding: EdgeInsets.fromLTRB(10.0, 20.0, 10.0, 10.0),
            child: Column(
              children: <Widget>[
                new TextField(
                  decoration: InputDecoration(labelText: "Title*"),
                ),
                new TextField(
                  decoration:
                  InputDecoration(labelText: "Available Space in Sqft*"),
                ),
                new TextField(
                  decoration: InputDecoration(labelText: "Available Space*"),
                ),
                new TextField(
                  decoration: InputDecoration(labelText: "Address*"),
                ),
                new TextField(
                  decoration: InputDecoration(labelText: "Contact Number*"),
                ),
                new ListTile(
                  title: const Text('Select Your Plan'),
                  trailing: new DropdownButton<String>(
                    value: "Hourly",
                    onChanged: (String newValue) {
                      print(newValue);
                    },
                    items:
                    <String>['Hourly', 'Weekly', 'Monthly'].map((String value) {
                      return new DropdownMenuItem<String>(
                        value: value,
                        child: new Text(value),
                      );
                    }).toList(),
                  ),
                ),
                new Container(
                  height: 1.0,
                  width: 1.0,
                  color: Colors.grey,
                ),
                new TextField(
                  decoration: InputDecoration(labelText: "Rate*"),
                )
              ],
            ),
          ),
        ),
      ),
    );
  }
}

How to save contact number in flutter

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