MODUL GO-COURSE APLIKASI GO-COURSE BERBASIS ......2 APLIKASI GO-COURSE BERBASIS ANDROID DENGAN...

Post on 04-Dec-2020

13 views 1 download

Transcript of MODUL GO-COURSE APLIKASI GO-COURSE BERBASIS ......2 APLIKASI GO-COURSE BERBASIS ANDROID DENGAN...

1

MODUL

GO-COURSE

APLIKASI GO-COURSE BERBASIS ANDROID DENGAN

METODE LOCATION BASED SERVICE

TIM:

Taufik Rahman

Muhammad Ulin Nuha

Herman Kuswanto

Hafis Nurdin

Sumarna

Felix Wuryo Handono

2020

2

APLIKASI GO-COURSE BERBASIS ANDROID DENGAN

MENGGUNAKAN METODE LOCATION BASE SERVICE

adalah aplikasi yang dibuat menggunakan bahasa pemrograman Android Studio,

Flutter dan database MySQL. Aplikasi yang mempermudah pengguna untuk lebih

mengetahui tentang Pare Kampung Inggris. Aplikasi ini menampilkan informasi

tentang Pare Kampung Inggris yang digunakan untuk wadah pencarian kursusan,

kos, camp serta rental kendaraan.

3

Berikut Tutorial Penggunaannya:

1. Tampilan masuk Aplikasi

Tampilan sebelum masuk ke menu utama pada apliksai Go-Course Pare

seperti pada gambar dibawa ini.

4

2. Menu Utama

User dapat memilih empat menu yaitu, Pencarian, Kursusan, Kos dan

Asrama dan PaketWisata seperti pada gambar di bawah ini.

5

3. Tampilan Menu Kos dan Asrama Go-Course Pare

Pada Menu Kos dan Asrama memiliki daftar menu Kos dan Asrama yaitu,

Button Detail Kos dan Asrama seperti pada gambar di bawah ini.

6

4. Paket Wisata Go-Course Pare

Pada bagian ini user dapat memilih paket wisata yang tersedia seperti pada

tampilan dibawah ini.

7

5. Button Navigasi dan Hubungi Pemilik Go-Course Pare

Pada bagian ini pengguna dapat mengetahui letak tempat yang dituju dari

titik awal user berada dan dapat menghubungi pemilik tempat melalui WhatsApp

seperti pada gambar di bawah ini.

Demikian proses yang dapat dijelaskan dari Aplikasi GO-COURSE Berbasis

Android dengan Menggunakan Metode Location Base Service

8

Source Code Program

Code Generation

A. Home

import 'dart:io';

import 'package:cloud_firestore/cloud_firestore.dart';

import 'package:flutter/material.dart';

import 'package:go_course/screen/kosdancamp.dart';

import 'package:go_course/screen/kursusan.dart';

import 'package:go_course/screen/profilkursus.dart';

import 'package:go_course/screen/profilwisata.dart';

import 'package:go_course/screen/searchservice.dart';

import 'package:go_course/screen/tentang.dart';

import 'package:go_course/screen/wisata.dart';

import 'package:go_course/setting/app.dart';

import 'package:go_course/setting/state.dart';

import 'package:go_course/setting/state_widget.dart';

import 'login.dart';

class HomeScreen extends StatefulWidget {

@override

State<StatefulWidget> createState() => new HomeScreenState();

}

class HomeScreenState extends State<HomeScreen> {

StateModel appState;

var queryResultSet = [];

var tempSearchStore = [];

bool _isSearching=false;

ScrollController _controller;

double appBarHeigh = 220.0;

double borderRadiusAppBar = 60;

_scrollListener() {

if (_controller.offset > _controller.position.minScrollExtent &&

!_controller.position.outOfRange) {

setState(() {

appBarHeigh = 75.0;

borderRadiusAppBar = 0.0;

});

} else if (_controller.offset <= _controller.position.minScrollExtent &&

!_controller.position.outOfRange) {

setState(() {

appBarHeigh = 220.0;

borderRadiusAppBar = 60.0;

9

});

}

}

@override

void initState() {

_controller = ScrollController();

_controller.addListener(_scrollListener);

super.initState();

}

Widget _buildStories({Widget body}) {

DocumentReference documentReference =

Firestore.instance.collection("paket_wisata").document();

return Scaffold(

drawer: new Drawer(

child: ListView(

children: <Widget>[

new UserAccountsDrawerHeader(

accountName: new Text('${appState.user.displayName}'),

decoration: BoxDecoration(

color: Colors.orange,

),

accountEmail: new Text('${appState.user.email}'),

currentAccountPicture: new GestureDetector(

// onTap: ()=>Navigator.of(context).push(new

MaterialPageRoute(

// //builder: (BuildContext contex)=> new Detail(nama:

nama1, gambar: gambar1,),

// )),

child: new CircleAvatar(

backgroundImage:

new NetworkImage(appState.user.photoUrl.toString()),

),

),

),

new ListTile(

title: new Text('Setting'),

trailing: new Icon(Icons.settings),

onTap: () {

// StateWidget.of(context).logOut();

Navigator.push(

context,

MaterialPageRoute(builder: (context) => About()),

);

},

),

new ListTile(

10

title: new Text('LogOut'),

onTap: () {

StateWidget.of(context).logOut();

Navigator.pushReplacement(

context,

MaterialPageRoute(

builder: (context) =>

new StateWidget(child: new MyApp())));

},

trailing: new Icon(Icons.people),

),

new ListTile(

title: new Text('Close'),

onTap: () => exit(0),

trailing: new Icon(Icons.close),

),

],

),

),

body: Container(

height: MediaQuery.of(context).size.height,

width: MediaQuery.of(context).size.width,

child: Column(

children: <Widget>[

new Container(

height: appBarHeigh,

child: new Stack(

children: <Widget>[

new Container(

height: appBarHeigh,

width: MediaQuery.of(context).size.width,

decoration: BoxDecoration(

color: Colors.orange,

borderRadius: BorderRadius.only(

bottomLeft: Radius.circular(borderRadiusAppBar))),

),

new AppBar(

title: Text(

'GO-COURSE PARE',

style: TextStyle(

color: Colors.white,

),

),

backgroundColor: Colors.transparent,

elevation: 0.0,

iconTheme: IconThemeData(

color: Colors.white,

11

),

),

new Positioned(

top: 80,

child: Column(

children: <Widget>[

new Container(

width: MediaQuery.of(context).size.width,

child: Center(

child: Padding(

padding: EdgeInsets.all(10),

child: new Text(

'Mau Mencari Apa...?',

style: TextStyle(

fontSize: 16,

color: Colors.white,

),

),

),

)),

new Container(

width: 300,

child: Center(

child: new TextField(

// onTap: (){

// setState(() {

// _isSearching=true;

// });

// },

onChanged: (value) {

if(value.length != 0) {

setState(() {

_isSearching=true;

});

initiateSearch(value);

print(value);

} else {

setState(() {

_isSearching=false;

});

}

},

decoration: InputDecoration(

border: OutlineInputBorder(

borderSide: BorderSide(

color: Colors.white,

),

12

borderRadius: BorderRadius.all(

Radius.circular(30),

)),

prefixIcon: Icon(

Icons.search,

color: Colors.white,

),

),

),

),

)

],

),

)

],

),

),

_isSearching == false ? new Expanded(

child: SingleChildScrollView(

controller: _controller,

child: Column(

children: <Widget>[

new GridView.builder(

itemCount: 3,

shrinkWrap: true,

physics: NeverScrollableScrollPhysics(),

itemBuilder: (context, index) {

String icon;

String nama;

Widget halaman;

if (index == 0) {

icon = 'assets/images/Picture5.png';

nama = 'Kursusan';

halaman = Kursusan();

} else if (index == 1) {

icon = 'assets/images/Picture6.png';

nama = 'Kos/Asrama';

halaman = KosdanCamp();

} else if (index == 2) {

icon = 'assets/images/Picture4.png';

nama = 'Paket Wisata';

halaman = Wisata();

}

return InkWell(

onTap: () {

Navigator.push(

13

context,

MaterialPageRoute(builder: (context) => halaman),

);

},

child: Card(

color: Colors.transparent,

elevation: 0.0,

child: Container(

child: Column(

children: <Widget>[

new Image.asset(

icon,

height: 64,

width: 64,

),

new Padding(

padding: EdgeInsets.all(5),

child: new Text(nama),

)

],

),

),

),

);

},

gridDelegate:

SliverGridDelegateWithFixedCrossAxisCount(

crossAxisCount: 3,

),

),

new ListTile(

title: Text(

'Wisata Rekomendasi',

style: TextStyle(

fontWeight: FontWeight.w600,

fontSize: 20.0,

),

),

trailing: Icon(Icons.keyboard_arrow_right),

),

StreamBuilder<QuerySnapshot>(

stream: Firestore.instance

.collection("paket_wisata")

.where("rekomendasi", isEqualTo: "1")

.snapshots(),

builder:

14

(context, AsyncSnapshot<QuerySnapshot> snapshot) {

if (!snapshot.hasData) {

return new Text("datat");

}

return new Container(

width: double.infinity,

height: 200.0,

padding: EdgeInsets.only(left: 8),

child: ListView(

scrollDirection: Axis.horizontal,

// itemCount: 3,

// itemBuilder: (context, index){

children: snapshot.data.documents

.map((DocumentSnapshot document) {

return InkWell(

onTap: () {

Navigator.push(

context,

MaterialPageRoute(

builder: (context) => ProfilWisata(

id: document["pw_id"])));

},

child: Card(

child: Column(

children: <Widget>[

new Container(

height: 100.0,

width: 250.0,

child: Image.network(

"${document["gambar_wisata"]}",

fit: BoxFit.fill,

),

),

new Container(

width: 250.0,

padding: EdgeInsets.only(

top: 10.0,

left: 10.0,

right: 10.0,

bottom: 5.0,

),

child: Text(

'Moment Tak Terlupakan',

style: TextStyle(

fontSize: 16.0,

fontWeight: FontWeight.bold,

),

),

15

),

new Container(

width: 250.0,

padding: EdgeInsets.only(

left: 10.0,

right: 10.0,

),

child: Text(

'Berbagai Wahana Unik Untuk Moment Asik

Bersama Keluarga',

style: TextStyle(

color: Colors.grey,

),

),

),

],

),

),

);

}).toList(),

),

);

}),

new ListTile(

title: Text(

'Kosakata Sehari-hari',

style: TextStyle(

fontWeight: FontWeight.w600,

fontSize: 20.0,

),

),

trailing: Icon(Icons.keyboard_arrow_right),

),

new Container(

width: double.infinity,

height: 230.0,

padding: EdgeInsets.only(left: 8),

child: ListView.builder(

scrollDirection: Axis.horizontal,

itemCount: 3,

itemBuilder: (context, index) {

return Card(

child: Column(

children: <Widget>[

new Container(

16

height: 200.0,

width: 300.0,

child: Image.network(

'https://firebasestorage.googleapis.com/v0/b/testing1-

3195b.appspot.com/o/vocabularies%2FIMG_20190728_044818.jpg?alt=

media&token=e5fb691a-7716-4b36-b874-235a41ccc843',

fit: BoxFit.fill,

),

),

],

),

);

},

),

),

],

),

),

): new Expanded(child: ListView(

shrinkWrap: true,

primary: false,

children: tempSearchStore.map((data){

return searchScreen(data);

}).toList(),

))

],

),

),

);

}

Widget _buildContent() {

if (appState.isLoading) {

return _buildLoadingIndicator();

} else if (!appState.isLoading && appState.user == null) {

return new LoginScreen();

} else {

return _buildStories();

}

}

Center _buildLoadingIndicator() {

return Center(

child: new CircularProgressIndicator(),

);

}

17

@override

Widget build(BuildContext context) {

// Build the content depending on the state:

appState = StateWidget.of(context).state;

return _buildContent();

}

initiateSearch(value) {

if (value.length == 0) {

setState(() {

queryResultSet = [];

tempSearchStore = [];

});

}

var capitalizedValue =

value.substring(0, 1).toUpperCase() + value.substring(1);

if (queryResultSet.length == 0 && value.length == 1) {

SerachService().searchByName(value).then((QuerySnapshot docs) {

for (int i = 0; i < docs.documents.length; ++i) {

queryResultSet.add(docs.documents[i].data);

}

});

} else {

tempSearchStore = [];

queryResultSet.forEach((element) {

if (element['nama_kursus'].startsWith(capitalizedValue)) {

setState(() {

tempSearchStore.add(element);

});

}

});

}

}

Widget searchScreen(document) {

return InkWell(

onTap: () {

Navigator.push(

context,

MaterialPageRoute(

builder: (context) => ProfilKursus(

id: document["cs_id"],

)),

);

},

child: Container(

18

height: 210,

color: Colors.blue,

margin: EdgeInsets.symmetric(vertical: 10),

child: Stack(

children: <Widget>[

Container(

height: 210,

width: MediaQuery.of(context).size.width,

child: new Image.network(

"${document["gambar"]}",

fit: BoxFit.fill)),

Positioned.fill(

top: 0,

left: 0,

right: 0,

bottom: 0,

child: Container(

padding: EdgeInsets.all(10),

color: Colors.black.withOpacity(0.2),

child: Column(

crossAxisAlignment: CrossAxisAlignment.start,

children: <Widget>[

new Text(

"${document["nama_kursus"]}",

style: TextStyle(

color: Colors.white,

fontSize: 18,

fontWeight: FontWeight.bold),

),

new Text(

"${document["ijin_diknas"]}",

style: TextStyle(

color: Colors.white,

fontSize: 14,

fontWeight: FontWeight.bold),

),

],

),

),

)

],

),

),

);

}

}

B. Tampilan Profile Kursusan

19

import 'package:cloud_firestore/cloud_firestore.dart';

import 'package:flutter/cupertino.dart';

import 'package:flutter/material.dart';

import 'package:url_launcher/url_launcher.dart';

class ProfilKursus extends StatefulWidget {

final String id;

ProfilKursus({this.id});

@override

_ProfilKursusState createState() => _ProfilKursusState();

}

class _ProfilKursusState extends State<ProfilKursus> {

List<String> programs;

String _currentProgram;

Widget rincianKursus = Text("Pilih Program Kursus");

Widget rincianProgram = Text("Pilih Program Kursus");

List<String> rincianPrograms = [];

void changeDropDownItem(String selectedProgram){

setState(() {

_currentProgram = selectedProgram;

});

}

@override

Widget build(BuildContext context) {

return Scaffold(

appBar: AppBar(

title: Text("GO-COURSE PARE",textAlign: TextAlign.center,),

backgroundColor: Colors.blue[500],

),

body: new Container(

child: StreamBuilder<QuerySnapshot>(

stream: Firestore.instance

.collection("kursusan_data")

.where("cs_id", isEqualTo: "${widget.id}")

.snapshots(),

builder: (context, AsyncSnapshot<QuerySnapshot> snapshot) {

if (snapshot.hasError) {

return new Text("error: ${snapshot.error}");

}

switch (snapshot.connectionState) {

case ConnectionState.waiting:

return new Text("Loading...");

break;

default:

20

return new ListView(

children: snapshot.data.documents

.map((DocumentSnapshot document) {

programs = new List<String>.from(document["program"]);

_currentProgram = programs[0].toString();

return new ListView(

shrinkWrap: true,

physics: NeverScrollableScrollPhysics(),

children: <Widget>[

new Image.network("${document["gambar"]}"),

new Container(

color: Colors.blue[500],

// margin: EdgeInsets.all(8.0),

padding: const EdgeInsets.symmetric(horizontal: 10),

child: new Row(

mainAxisAlignment: MainAxisAlignment.spaceBetween,

children: [

Expanded(flex: 1,

child: new Container(

padding: const EdgeInsets.all(8.0),

child: new Text(

"${document["nama_kursus"]}",

style: new TextStyle(

fontWeight: FontWeight.bold,

fontSize: 16.0,

color: Colors.white),

),

),

),

Expanded( flex: 1,

child: new Container(

//width: MediaQuery.of(context).size.width,

padding: const EdgeInsets.all(8.0),

child: new DropdownButton(

value: _currentProgram,

items: programs.map((data){

return new DropdownMenuItem(

value: data,

child: Text(

data,

style: new TextStyle(

fontSize: 16.0,

color: Colors.black

),

),

);

}).toList(),

onChanged: (val){

21

setState(() {

_currentProgram = val;

rincianKursus = new StreamBuilder<QuerySnapshot>(

stream: Firestore.instance

.collection("kursusan_data")

.document(widget.id)

.collection(_currentProgram)

// .where("cs_id", isEqualTo: "${widget.id}")

.snapshots(),

builder: (context, AsyncSnapshot<QuerySnapshot>

snapshot1) {

if(snapshot1.hasError){

return new Text("error: ${snapshot1.error}");

}

switch (snapshot1.connectionState) {

case ConnectionState.waiting:

return Text("Loading...");

break;

default:

return new ListView(

shrinkWrap: true,

physics: NeverScrollableScrollPhysics(),

children:

snapshot1.data.documents.map((DocumentSnapshot docPaket){

return ListTile(

title: Text('${docPaket['paket']}'),

subtitle: StreamBuilder<QuerySnapshot>(

stream: Firestore.instance

.collection("kursusan_data")

.document(widget.id)

.collection(_currentProgram)

.document('${docPaket['paket']}')

.collection('Kelas')

// .where("cs_id", isEqualTo: "${widget.id}")

.snapshots(),

builder: (context, AsyncSnapshot<QuerySnapshot>

snapshot2) {

if(snapshot2.hasError){

return new Text("error: ${snapshot2.error}");

}

switch (snapshot2.connectionState) {

case ConnectionState.waiting:

return Text("Loading...");

break;

default:

return new ListView(

shrinkWrap: true,

22

physics: NeverScrollableScrollPhysics(),

children:

snapshot2.data.documents.map((DocumentSnapshot docKelas){

return Row(

// mainAxisAlignment:

MainAxisAlignment.spaceBetween,

children: <Widget>[

Expanded(

flex: 1,

child: new Text('${docKelas['kelas']}')

),

Expanded(

flex: 1,

child: new Text('${docKelas['durasi']}',

textAlign: TextAlign.right,)

),

Expanded(

flex: 1,

child: new Text('${docKelas['harga']}',

textAlign: TextAlign.right,)

),

],

);

}).toList(),

);

}}

),

);

}).toList(),

);

}

}

);

rincianProgram = new StreamBuilder<QuerySnapshot>(

stream: Firestore.instance

.collection("kursusan_data")

.document(widget.id)

.collection(_currentProgram)

// .where("cs_id", isEqualTo: "${widget.id}")

.snapshots(),

builder: (context, AsyncSnapshot<QuerySnapshot>

snapshot1) {

if(snapshot1.hasError){

return new Text("error: ${snapshot1.error}");

}

switch (snapshot1.connectionState) {

23

case ConnectionState.waiting:

return Text("Loading...");

break;

default:

return new ListView(

shrinkWrap: true,

physics: NeverScrollableScrollPhysics(),

children:

snapshot1.data.documents.map((DocumentSnapshot docPaket){

return Container(

//title: Text('${docPaket['paket']}'),

child: StreamBuilder<QuerySnapshot>(

stream: Firestore.instance

.collection("kursusan_data")

.document(widget.id)

.collection(_currentProgram)

.document('${docPaket['paket']}')

.collection('Kelas')

// .where("cs_id", isEqualTo: "${widget.id}")

.snapshots(),

builder: (context, AsyncSnapshot<QuerySnapshot>

snapshot2) {

if(snapshot2.hasError){

return new Text("error: ${snapshot2.error}");

}

switch (snapshot2.connectionState) {

case ConnectionState.waiting:

return Text("Loading...");

break;

default:

return new ListView(

shrinkWrap: true,

physics: NeverScrollableScrollPhysics(),

children:

snapshot2.data.documents.map((DocumentSnapshot docKelas){

rincianPrograms = new

List<String>.from(docKelas["rincian_program"]);

return Column(

children: <Widget>[

Container(

width: MediaQuery.of(context).size.width,

margin: EdgeInsets.only(

left: 10,

top: 10

),

child: Text(

'${docKelas['kelas']}',

style: TextStyle(

24

fontWeight: FontWeight.bold

),

)

),

GridView(padding: EdgeInsets.all(30),

shrinkWrap: true,

physics: NeverScrollableScrollPhysics(),

gridDelegate:

SliverGridDelegateWithFixedCrossAxisCount(

crossAxisCount: 2,childAspectRatio:

10,crossAxisSpacing: 20,mainAxisSpacing: 20,

),

children: rincianPrograms.map((doc) {

return Container(

child: new Text("- ${doc}"));

}).toList(),

),

],

);

}).toList(),

);

}}

),

);

}).toList(),

);

}

}

);

});

print(val);

print(_currentProgram);

},

),

),

),

],

),

),

rincianKursus,

new Container(

width: MediaQuery.of(context).size.width,

padding: const EdgeInsets.all(8.0),

25

margin: EdgeInsets.only(top: 20),

color: Colors.blue[500],

child: new Text(

"Fasilitas",

style: TextStyle(

fontWeight: FontWeight.bold,

fontSize: 16.0,

color: Colors.white),

),

),

rincianProgram,

// GridView(padding: EdgeInsets.all(30),

// shrinkWrap: true,

// physics: NeverScrollableScrollPhysics(),

// gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(

// crossAxisCount: 2,childAspectRatio: 10,crossAxisSpacing:

20,mainAxisSpacing: 20,

// ),

// children: fiture.map((doc) {

// return Container(

// child: new Text(" "));

// }).toList(),

// ),

Row(

mainAxisAlignment: MainAxisAlignment.center,

mainAxisSize: MainAxisSize.max,

children: <Widget>[

Expanded(

flex: 2,

child: Container(margin: EdgeInsets.symmetric(horizontal: 10),

child: new RaisedButton(

padding: EdgeInsets.all(10.0),

child: Text("Navigasi Map",

style: TextStyle(color: Colors.white)),

color: Colors.blue,

onPressed: () {

openMap(double.parse(document["latitude"]),

double.parse(document["longitude"]));

print(

'https://www.google.com/maps/search/?api=1&query=${document["latitude"]},${

document["longitude"]}');

},

),

),

),

26

Expanded(

flex: 2,

child: Container(

margin: EdgeInsets.symmetric(horizontal: 10),

child: new RaisedButton(

padding: EdgeInsets.all(10.0),

child: Text("Hubungi Pemilik",

style: TextStyle(color: Colors.white)),

color: Colors.blue,

onPressed: () {

openWa("${document["no_hp"]}");

// openMap(double.parse(document["latitude"]),

// double.parse(document["longitude"]));

print(

'https://www.wa.me/6282337700079=${document["no_hp"]}');

},

),

),

),

],

),

],

);

}).toList());

}

},

),

),

);

}

static openMap(double latitude, double longitude) async {

String googleUrl =

'https://www.google.com/maps/search/?api=1&query=$latitude,$longitude';

if (await canLaunch(googleUrl)) {

await launch(googleUrl);

} else {

throw 'Could not open the map.';

}

}

static openWa(String phone) async {

String waUrl =

'whatsapp://send?phone=$phone';

if (await canLaunch(waUrl)) {

await launch(waUrl);

27

} else {

throw 'Could not open the map.';

}

}

}

C. Profile Wisata

import 'package:cloud_firestore/cloud_firestore.dart';

import 'package:flutter/material.dart';

import 'package:url_launcher/url_launcher.dart';

class ProfilWisata extends StatefulWidget {

final String id;

ProfilWisata({this.id});

@override

_ProfilWisataState createState() => _ProfilWisataState();

}

class _ProfilWisataState extends State<ProfilWisata> {

List<String> fiture;

@override

Widget build(BuildContext context) {

return Scaffold(

appBar: AppBar(

title: Text("GO-COURSE PARE",textAlign: TextAlign.center,),

backgroundColor: Colors.blue[500],

),

body: new Container(

child: StreamBuilder<QuerySnapshot>(

stream: Firestore.instance

.collection("paket_wisata")

.where("pw_id", isEqualTo: "${widget.id}")

.snapshots(),

builder: (context, AsyncSnapshot<QuerySnapshot> snapshot) {

if (snapshot.hasError) {

return new Text("error: ${snapshot.error}");

}

switch (snapshot.connectionState) {

case ConnectionState.waiting:

return new Text("Loading...");

break;

default:

return new ListView(

children: snapshot.data.documents

.map((DocumentSnapshot document) {

28

fiture = new

List<String>.from(document["fasilitas_lengkap"]);

return new ListView(

shrinkWrap: true,

physics: NeverScrollableScrollPhysics(),

children: <Widget>[

new Image.network("${document["gambar_wisata"]}"),

new Container(

color: Colors.blue[500],

// margin: EdgeInsets.all(8.0),

padding: const EdgeInsets.symmetric(horizontal: 10),

child: new Row(

mainAxisAlignment: MainAxisAlignment.spaceBetween,

children: [

new Container(

padding: const EdgeInsets.all(8.0),

child: new Text(

"${document["nama_travel"]}",

style: new TextStyle(

fontWeight: FontWeight.bold,

fontSize: 16.0,

color: Colors.white),

),

),

new Container(

//width: MediaQuery.of(context).size.width,

padding: const EdgeInsets.all(8.0),

child: new Text(

"${document["nama_wisata"]}",

style: TextStyle(

fontWeight: FontWeight.bold,

fontSize: 16.0,

color: Colors.white,

),

),

),

],

),

),

new DataTable(

columns: <DataColumn>[

// DataColumn(label: Text('Periode')),

DataColumn(label: Text('Orang')),

DataColumn(label: Text('Harga')),

],

rows: <DataRow>[

// DataRow(cells: <DataCell>[

// DataCell(Text('Harian')),

29

// DataCell(Text('umum')),

// DataCell(Text('${document['harga_harian']}'))

// ]),

// DataRow(cells: <DataCell>[

// DataCell(Text('Mingguan')),

// DataCell(Text('umum')),

// DataCell(Text('${document['harga_mingguan']}'))

// ]),

// DataRow(cells: <DataCell>[

// DataCell(Text('Bulanan')),

// DataCell(Text('1 Orang')),

// DataCell(Text('${document['harga_bulan']}'))

// ]),

DataRow(cells: <DataCell>[

// DataCell(Text('Bulanan')),

DataCell(Text('1 Orang')),

DataCell(Text('${document['harga_wisata']}'))

]),

DataRow(cells: <DataCell>[

// DataCell(Text('Bulanan')),

DataCell(Text('16 Orang')),

DataCell(Text('${document['harga_wisata2']}'))

]),

],

),

new Container(

width: MediaQuery.of(context).size.width,

padding: const EdgeInsets.all(8.0),

color: Colors.blue[500],

child: new Text(

"Fasilitas",

style: TextStyle(

fontWeight: FontWeight.bold,

fontSize: 16.0,

color: Colors.white),

),

),

GridView(padding: EdgeInsets.all(30),

shrinkWrap: true,

physics: NeverScrollableScrollPhysics(),

gridDelegate:

SliverGridDelegateWithFixedCrossAxisCount(

crossAxisCount: 2,childAspectRatio:

10,crossAxisSpacing: 20,mainAxisSpacing: 20,

),

children: fiture.map((doc) {

return Container(

30

child: new Text("- ${doc}"));

}).toList(),

),

Row(

mainAxisAlignment: MainAxisAlignment.center,

mainAxisSize: MainAxisSize.max,

children: <Widget>[

Expanded(

flex: 2,

child: Container(margin:

EdgeInsets.symmetric(horizontal: 10),

child: new RaisedButton(

padding: EdgeInsets.all(10.0),

child: Text("Navigasi Map",

style: TextStyle(color: Colors.white)),

color: Colors.blue,

onPressed: () {

openMap(double.parse(document["latitude"]),

double.parse(document["longitude"]));

print(

'https://www.google.com/maps/search/?api=1&query=${document["latitu

de"]},${document["longitude"]}');

},

),

),

),

Expanded(

flex: 2,

child: Container(

margin: EdgeInsets.symmetric(horizontal: 10),

child: new RaisedButton(

padding: EdgeInsets.all(10.0),

child: Text("Hubungi Pemilik",

style: TextStyle(color: Colors.white)),

color: Colors.blue,

onPressed: () {

openWa("${document["no_hp"]}");

// openMap(double.parse(document["latitude"]),

// double.parse(document["longitude"]));

print(

'https://www.wa.me/6282337700079=${document["no_hp"]}');

},

),

),

),

],

31

),

],

);

}).toList());

}

},

),

),

);

}

static openMap(double latitude, double longitude) async {

String googleUrl =

'https://www.google.com/maps/search/?api=1&query=$latitude,$longitude

';

if (await canLaunch(googleUrl)) {

await launch(googleUrl);

} else {

throw 'Could not open the map.';

}

}

static openWa(String phone) async {

String waUrl =

'whatsapp://send?phone=$phone';

if (await canLaunch(waUrl)) {

await launch(waUrl);

} else {

throw 'Could not open the map.';

}

}

}

D. Profil

import 'dart:math';

import 'package:cloud_firestore/cloud_firestore.dart';

import 'package:flutter/cupertino.dart';

import 'package:flutter/material.dart';

import 'package:flutter/rendering.dart';

import 'package:url_launcher/url_launcher.dart';

class Profil extends StatefulWidget {

final String id;

Profil({this.id});

@override

32

_ProfilState createState() => _ProfilState();

}

class _ProfilState extends State<Profil> {

List<String> fiture;

@override

Widget build(BuildContext context) {

return Scaffold(

appBar: AppBar(

title: Text(

"GO-COURSE PARE",

textAlign: TextAlign.center,

),

backgroundColor: Colors.orange,

),

body: new Container(

child: StreamBuilder<QuerySnapshot>(

stream: Firestore.instance

.collection("kos_camp")

.where("ks_id", isEqualTo: "${widget.id}")

.snapshots(),

builder: (context, AsyncSnapshot<QuerySnapshot> snapshot) {

if (snapshot.hasError) {

return new Text("error: ${snapshot.error}");

}

switch (snapshot.connectionState) {

case ConnectionState.waiting:

return new Text("Loading...");

break;

default:

return new ListView(

children: snapshot.data.documents

.map((DocumentSnapshot document) {

fiture = new List<String>.from(document["fiture"]);

return new ListView(

shrinkWrap: true,

physics: NeverScrollableScrollPhysics(),

children: <Widget>[

new Image.network("${document["images"]}"),

new Container(

color: Colors.orange,

// margin: EdgeInsets.all(8.0),

padding: const EdgeInsets.symmetric(horizontal: 10),

child: new Row(

mainAxisAlignment: MainAxisAlignment.spaceBetween,

children: [

new Container(

child: new Text(

33

"${document["nama_kos"]}",

style: new TextStyle(

fontWeight: FontWeight.bold,

fontSize: 16.0,

color: Colors.white),

),

),

new Container(

//width: MediaQuery.of(context).size.width,

padding: const EdgeInsets.all(8.0),

child: new Text(

"${document["jumlah_kamar"]}",

style: TextStyle(

color: Colors.white,

),

),

),

],

),

),

new DataTable(

columns: <DataColumn>[

DataColumn(label: Text('Periode')),

DataColumn(label: Text('Orang')),

DataColumn(label: Text('Harga')),

],

rows: <DataRow>[

DataRow(cells: <DataCell>[

DataCell(Text('Harian')),

DataCell(Text('umum')),

DataCell(Text('${document['harga_harian']}'))

]),

DataRow(cells: <DataCell>[

DataCell(Text('Mingguan')),

DataCell(Text('umum')),

DataCell(Text('${document['harga_mingguan']}'))

]),

DataRow(cells: <DataCell>[

DataCell(Text('Bulanan')),

DataCell(Text('1 Orang')),

DataCell(Text('${document['harga_bulan']}'))

]),

DataRow(cells: <DataCell>[

DataCell(Text('Bulanan')),

DataCell(Text('2 Orang')),

DataCell(Text('${document['harga_bulan_berdua']}'))

]),

// DataRow(cells: <DataCell>[

34

// DataCell(Text('Bulanan')),

// DataCell(Text('3 Orang')),

// DataCell(Text('${document['harga_bulan_bertiga']}'))

// ]),

],

),

new Container(

width: MediaQuery.of(context).size.width,

padding: const EdgeInsets.all(8.0),

color: Colors.orange,

child: new Text(

"Fasilitas",

style: TextStyle(

fontWeight: FontWeight.bold,

fontSize: 16.0,

color: Colors.white),

),

),

GridView(padding: EdgeInsets.all(30),

shrinkWrap: true,

physics: NeverScrollableScrollPhysics(),

gridDelegate:

SliverGridDelegateWithFixedCrossAxisCount(

crossAxisCount: 2,childAspectRatio:

10,crossAxisSpacing: 20,mainAxisSpacing: 20,

),

children: fiture.map((doc) {

return Container(

child: new Text("- ${doc}"));

}).toList(),

),

Row(

mainAxisAlignment: MainAxisAlignment.center,

mainAxisSize: MainAxisSize.max,

children: <Widget>[

Expanded(

flex: 2,

child: Container(margin:

EdgeInsets.symmetric(horizontal: 10),

child: new RaisedButton(

padding: EdgeInsets.all(10.0),

child: Text("Navigasi Map",

style: TextStyle(color: Colors.white)),

color: Colors.blue,

onPressed: () {

openMap(double.parse(document["latitude"]),

double.parse(document["longitude"]));

35

print(

'https://www.google.com/maps/search/?api=1&query=${document["latitu

de"]},${document["longitude"]}');

},

),

),

),

Expanded(

flex: 2,

child: Container(

margin: EdgeInsets.symmetric(horizontal: 10),

child: new RaisedButton(

padding: EdgeInsets.all(10.0),

child: Text("Hubungi Pemilik",

style: TextStyle(color: Colors.white)),

color: Colors.blue,

onPressed: () {

openWa("${document["no_hp"]}");

// openMap(double.parse(document["latitude"]),

// double.parse(document["longitude"]));

print(

'https://www.wa.me/62895331123914=${document["no_hp"]}');

},

),

),

),

],

),

],

);

}).toList());

}

},

),

),

);

}

static openMap(double latitude, double longitude) async {

String googleUrl =

'https://www.google.com/maps/search/?api=1&query=$latitude,$longitude

';

if (await canLaunch(googleUrl)) {

await launch(googleUrl);

36

} else {

throw 'Could not open the map.';

}

}

static openWa(String phone) async {

String waUrl =

'whatsapp://send?phone=$phone';

if (await canLaunch(waUrl)) {

await launch(waUrl);

} else {

throw 'Could not open the map.';

}

}

}

E. Kost dan Camp

import 'package:cloud_firestore/cloud_firestore.dart';

import 'package:flutter/material.dart';

import 'package:flutter/services.dart';

import 'package:go_course/screen/profil.dart';

class KosdanCamp extends StatefulWidget {

@override

_KosdanCamp createState() => _KosdanCamp();

}

class _KosdanCamp extends State<KosdanCamp> with

SingleTickerProviderStateMixin {

TabController controller;

@override

void initState() {

controller = new TabController(vsync: this, length: 2);

super.initState();

}

@override

void dispose() {

controller.dispose();

super.dispose();

}

@override

Widget build(BuildContext context) {

SystemChrome.setSystemUIOverlayStyle(

37

SystemUiOverlayStyle.dark.copyWith(statusBarColor: Colors.black));

return Scaffold(

appBar: AppBar(

title: Text('Kos dan Asrama', style: TextStyle(color: Colors.white),),

backgroundColor: Colors.orange,

),

body: LihatDaftar(),

);

}

}

class LihatMap extends StatelessWidget {

@override

Widget build(BuildContext context) {

return Scaffold(

body: Column(

children: <Widget>[

],

),

);

}

}

class LihatDaftar extends StatelessWidget {

@override

Widget build(BuildContext context) {

return Scaffold(

body: new Container(

child: StreamBuilder<QuerySnapshot>(

stream: Firestore.instance.collection("kos_camp").snapshots(),

builder: (context, AsyncSnapshot<QuerySnapshot> snapshot){

if(snapshot.hasError){

return new Text("error: ${snapshot.error}");

}

switch (snapshot.connectionState) {

case ConnectionState.waiting : return new Text("Loading...");

break;

default:

return new ListView(

children: snapshot.data.documents

.map((DocumentSnapshot document){

return new Container(

width: MediaQuery.of(context).size.width,

padding: new EdgeInsets.symmetric(horizontal: 10.0, vertical:

5.0),

child: InkWell(

38

onTap: (){

Navigator.push(

context,

MaterialPageRoute(builder: (context) => Profil(id:

document["ks_id"],) ),

);

},

child: Card(

elevation: 5.0,

shape: RoundedRectangleBorder(

borderRadius: BorderRadius.circular(0.0),

),

child: Container(

width: MediaQuery.of(context).size.width,

child: Row(

mainAxisAlignment: MainAxisAlignment.start,

crossAxisAlignment: CrossAxisAlignment.start,

children: <Widget>[

new Container(

width: 80.0,

height: 140.0,

color: Colors.green,

child: Image.network("${document["images"]}", fit:

BoxFit.fill,),

),

new Container(

padding: EdgeInsets.all(10.0),

child: new Column(

crossAxisAlignment: CrossAxisAlignment.start,

children: <Widget>[

new Text("${document["nama_kos"]}",

style: TextStyle(

fontWeight: FontWeight.bold,

fontSize: 16.0

),),

new Row(

children: <Widget>[

new Container(

padding: EdgeInsets.symmetric(

vertical: 5.0,

),

child: new Text(

"${document["jenis_kelamin"]}",

style: TextStyle(

color: Colors.blue

)

)

39

),

new Icon(Icons.star),

new Text("4.0"),

],

),

new Row(

children: <Widget>[

new Icon(Icons.location_on),

new Text("${document["alamat_kos"]}"),

],

),

new Container(

margin: EdgeInsets.only(

top: 15.0,

),

child: Text("Rp. ${document["harga_bulan"]}"),

),

new Text("Ada: ${document["jumlah_kamar"]}"),

],

),

),

],

),

),

),

),

);

}).toList(),

);

}

},

),

),

);

}

}

F. Login

import 'package:flutter/cupertino.dart';

import 'package:flutter/material.dart';

import 'package:go_course/setting/state_widget.dart';

class LoginScreen extends StatefulWidget {

@override

_LoginScreenState createState() => _LoginScreenState();

}

class _LoginScreenState extends State<LoginScreen> {

@override

40

Widget build(BuildContext context) {

return new Scaffold(

resizeToAvoidBottomPadding: true,

body: new ListView(

shrinkWrap: true,

reverse: false,

children: <Widget>[

new SizedBox(

height: 20.0,

),

new Column(

mainAxisAlignment: MainAxisAlignment.center,

children: <Widget>[

new Row(

children: <Widget>[

// Image.asset("assets/background.png",

// height: MediaQuery.of(context).size.height,

// width: MediaQuery.of(context).size.width/1.0,

// fit: BoxFit.fill,

//),

Padding(

padding: EdgeInsets.only(left: 20.0, bottom: 10.0),

child: new Text(" ",

style: TextStyle(

fontWeight: FontWeight.bold,

fontSize: 15.0,

),

textAlign: TextAlign.left),

)

],

),

new Image.asset(

"assets/logoo.jpg",

height: 150.0,

width: 210.0,

fit: BoxFit.scaleDown,

),

Container(

child: Text("Go-Course Kampung Inggris",style:

TextStyle(fontSize: 16,fontWeight: FontWeight.bold)),

margin: EdgeInsets.only(top: 10),

),

new SizedBox(

height: 30.0,

),

41

// new Column(

// mainAxisAlignment: MainAxisAlignment.center,

// children: <Widget>[

// new Image.asset(

// "assets/logoo.png",

// height: 150.0,

// width: 210.0,

// fit: BoxFit.scaleDown,

// )

// ],

// ),

new SizedBox(

height: 50.0,

),

Center(

child: RaisedButton(

onPressed: () =>

StateWidget.of(context).signInWithGoogle(),

padding:

EdgeInsets.only(top: 3.0, bottom: 3.0, left: 3.0),

color: const Color(0xFFFFFFFF),

child: new Row(

mainAxisSize: MainAxisSize.min,

children: <Widget>[

new Image.asset(

'assets/SignIn.png',

height: 60.0,

),

// new Container(

// padding: EdgeInsets.only(left: 10.0, right: 10.0),

// child: new Text(

// "Sign in with Google",

// style: TextStyle(

// color: Colors.grey,

// fontWeight: FontWeight.bold

// ),

// )

// ),

],

)),

)

],

)

],

));

42

// return Scaffold(

// appBar: AppBar(

// backgroundColor: Colors.blue,

// title: Text('Google Login'),

// ),

// body: Container(

// child: Center(

// child: Column(

// mainAxisAlignment: MainAxisAlignment.center,

// children: <Widget>[

// RaisedButton(

// onPressed: () =>

StateWidget.of(context).signInWithGoogle(),

// padding: EdgeInsets.only(top: 3.0, bottom: 3.0, left: 3.0),

// color: const Color(0xFFFFFFFF),

// child: new Row(

// mainAxisSize: MainAxisSize.min,

// children: <Widget>[

// new Image.asset(

// 'asset/google_button.jpg',

// height: 40.0,

// ),

// new Container(

// padding: EdgeInsets.only(left: 10.0, right: 10.0),

// child: new Text(

// "Sign in with Google",

// style: TextStyle(

// color: Colors.grey,

// fontWeight: FontWeight.bold),

// )),

// ],

// )

// ),

// ],

// ),

// ),

// ),

// );

}

}

G. Wisata

import 'package:cloud_firestore/cloud_firestore.dart';

import 'package:flutter/material.dart';

import 'package:flutter/painting.dart';

import 'package:flutter/services.dart';

import 'package:go_course/screen/profil.dart';

import 'package:go_course/screen/profilwisata.dart';

43

class Wisata extends StatefulWidget {

@override

_Wisata createState() => _Wisata();

}

class _Wisata extends State<Wisata> with

SingleTickerProviderStateMixin {

TabController controller;

@override

void initState() {

controller = new TabController(vsync: this, length: 2);

super.initState();

}

@override

void dispose() {

controller.dispose();

super.dispose();

}

@override

Widget build(BuildContext context) {

SystemChrome.setSystemUIOverlayStyle(

SystemUiOverlayStyle.dark.copyWith(statusBarColor: Colors.black));

return Scaffold(

appBar: AppBar(

title: Text('Paket Wisata', style: TextStyle(color: Colors.white),),

backgroundColor: Colors.blue[500],

),

body: LihatDaftar(),

);

}

}

class LihatMap extends StatelessWidget {

@override

Widget build(BuildContext context) {

return Scaffold(

body: Column(

children: <Widget>[

],

),

);

}

44

}

class LihatDaftar extends StatelessWidget {

@override

Widget build(BuildContext context) {

return Scaffold(

body: new Container(

child: StreamBuilder<QuerySnapshot>(

stream: Firestore.instance.collection("paket_wisata").snapshots(),

builder: (context, AsyncSnapshot<QuerySnapshot> snapshot){

if(snapshot.hasError){

return new Text("error: ${snapshot.error}");

}

switch (snapshot.connectionState) {

case ConnectionState.waiting : return new Text("Loading...");

break;

default:

return new ListView(

children: snapshot.data.documents

.map((DocumentSnapshot document){

return InkWell(

onTap: (){

Navigator.push(

context,

MaterialPageRoute(builder: (context) =>

ProfilWisata(id: document["pw_id"],) ),

);

},

child: Container(

height: 210, color: Colors.blue, margin:

EdgeInsets.symmetric(vertical: 10),

child: Stack(

children: <Widget>[

Container(

height: 210,

width: MediaQuery.of(context).size.width,

child: new Image.network(

"${document["gambar_wisata"]}",

fit: BoxFit.fill

)

),

Positioned.fill(

top: 0,

left: 0,

right: 0,

bottom: 0,

child: Container(

padding: EdgeInsets.all(10),

45

color: Colors.black.withOpacity(0.2),

child: Column(

crossAxisAlignment: CrossAxisAlignment.start,

children: <Widget>[

new Text("${document["nama_wisata"]}",

style: TextStyle(

color: Colors.white,

fontSize: 18, fontWeight: FontWeight.bold),

),

new Text("${document["harga_wisata"]}",

style: TextStyle(

color: Colors.white,

fontSize: 14, fontWeight: FontWeight.bold),

),

],

),

),

// Padding(

// padding: const EdgeInsets.only(top: 10),

// child: new Text("${document["nama_wisata"]}", style:

TextStyle(fontSize: 15),),

// ),

// Container(

// padding: const EdgeInsets.symmetric(horizontal: 10),

// child: Row(mainAxisAlignment:

MainAxisAlignment.spaceBetween,

// children: [

// new Text("${document["harga_wisata"]}",

// style: TextStyle(fontSize: 15,fontWeight:

FontWeight.bold)),

// ],

// )),

)],

),

),

);

}).toList(),

);

}

},

),

),

);

}

}

H. Kursus

import 'package:cloud_firestore/cloud_firestore.dart';

46

import 'package:flutter/material.dart';

import 'package:flutter/services.dart';

import 'package:go_course/screen/profilkursus.dart';

class Kursusan extends StatefulWidget {

@override

_Kursusan createState() => _Kursusan();

}

class _Kursusan extends State<Kursusan> with

SingleTickerProviderStateMixin {

@override

TabController controller;

@override

void initState() {

controller = new TabController(vsync: this, length: 2);

super.initState();

}

@override

void dispose() {

controller.dispose();

super.dispose();

}

Widget build(BuildContext context) {

SystemChrome.setSystemUIOverlayStyle(

SystemUiOverlayStyle.dark.copyWith(statusBarColor:

Colors.black));

return Scaffold(

appBar: AppBar(

title: Text(

'Kursusan',

style: TextStyle(color: Colors.white),

),

backgroundColor: Colors.blue,

),

body: LihatDaftar(),

);

}

}

class LihatDaftar extends StatelessWidget {

@override

Widget build(BuildContext context) {

return Scaffold(

47

body: new Container(

child: StreamBuilder<QuerySnapshot>(

stream: Firestore.instance.collection("kursusan_data").snapshots(),

builder: (context, AsyncSnapshot<QuerySnapshot> snapshot) {

if (snapshot.hasError) {

return new Text("error: ${snapshot.error}");

}

switch (snapshot.connectionState) {

case ConnectionState.waiting:

return new Text("Loading...");

break;

default:

return new ListView(

children:

snapshot.data.documents.map((DocumentSnapshot

document) {

return InkWell(

onTap: () {

Navigator.push(

context,

MaterialPageRoute(

builder: (context) => ProfilKursus(

id: document["cs_id"],

)),

);

},

child: Container(

height: 210,

color: Colors.blue,

margin: EdgeInsets.symmetric(vertical: 10),

child: Stack(

children: <Widget>[

Container(

height: 210,

width: MediaQuery.of(context).size.width,

child: new Image.network(

"${document["gambar"]}",

fit: BoxFit.fill)),

Positioned.fill(

top: 0,

left: 0,

right: 0,

bottom: 0,

child: Container(

padding: EdgeInsets.all(10),

color: Colors.black.withOpacity(0.2),

child: Column(

crossAxisAlignment: CrossAxisAlignment.start,

48

children: <Widget>[

new Text(

"${document["nama_kursus"]}",

style: TextStyle(

color: Colors.white,

fontSize: 18,

fontWeight: FontWeight.bold),

),

new Text(

"${document["ijin_diknas"]}",

style: TextStyle(

color: Colors.white,

fontSize: 14,

fontWeight: FontWeight.bold),

),

],

),

),

)

],

),

),

);

}).toList(),

);

}

},

),

),

);

}

}

I. Cari

import 'package:cloud_firestore/cloud_firestore.dart';

import 'package:flutter/material.dart';

import 'package:go_course/screen/searchservice.dart';

class InitiateSearch extends StatefulWidget {

final value;

const InitiateSearch({Key key, this.value}) : super(key: key);

@override

_InitiateSearchState createState() => _InitiateSearchState();

}

class _InitiateSearchState extends State<InitiateSearch> {

var queryResultSet = [];

49

var tempSearchStore = [];

@override

Widget build(BuildContext context) {

return ListView(

shrinkWrap: true,

primary: false,

children: tempSearchStore.map((data) {

initiateSearch(widget.value);

return InkWell(

onTap: () {},

child: new Container(

height: 210,

color: Colors.blue,

margin: EdgeInsets.symmetric(vertical: 10),

child: Stack(

children: <Widget>[

Container(

height: 210,

width: MediaQuery.of(context).size.width,

child: new Image.network("${data["gambar"]}",

fit: BoxFit.fill)),

Positioned.fill(

top: 0,

left: 0,

right: 0,

bottom: 0,

child: Container(

padding: EdgeInsets.all(10),

color: Colors.black.withOpacity(0.2),

child: Column(

crossAxisAlignment: CrossAxisAlignment.start,

children: <Widget>[

new Text(

"${data["nama_kursus"]}",

style: TextStyle(

color: Colors.white,

fontSize: 18,

fontWeight: FontWeight.bold),

),

],

),

),

)

],

),

),

);

50

}).toList(),

);

}

initiateSearch(value){

if(value.length == 0){

setState(() {

queryResultSet = [];

tempSearchStore = [];

});

}

var capitalzedValue = value.subString(0,1).toUpperCase() +

value.subString(1);

if(queryResultSet.length == 0 && value.length ==1){

SerachService().searchByName(value).then((QuerySnapshot docs) {

for (int i = 0; i< docs.documents.length; ++i) {

queryResultSet.add(docs.documents[i].data);

}

});

} else {

tempSearchStore = [];

queryResultSet.forEach((element){

if (element['nama_kursus'].starsWith(capitalzedValue)) {

setState((){

tempSearchStore.add(element);

});

}

});

}

}

}

J. State Widget

import 'dart:async';

import 'package:flutter/foundation.dart';

import 'package:flutter/material.dart';

import 'package:google_sign_in/google_sign_in.dart';

import 'package:firebase_auth/firebase_auth.dart';

import 'state.dart';

import 'auth.dart';

class StateWidget extends StatefulWidget {

final StateModel state;

final Widget child;

StateWidget({

@required this.child,

this.state,

});

51

// Returns data of the nearest widget _StateDataWidget

// in the widget tree.

static _StateWidgetState of(BuildContext context) {

return (context.inheritFromWidgetOfExactType(_StateDataWidget)

as _StateDataWidget)

.data;

}

@override

_StateWidgetState createState() => new _StateWidgetState();

}

class _StateWidgetState extends State<StateWidget> {

StateModel state;

GoogleSignInAccount googleAccount;

final GoogleSignIn googleSignIn = new GoogleSignIn();

@override

void initState() {

super.initState();

if (widget.state != null) {

state = widget.state;

} else {

state = new StateModel(isLoading: true);

initUser();

}

}

Future<Null> initUser() async {

googleAccount = await getSignedInAccount(googleSignIn);

if (googleAccount == null) {

setState(() {

state.isLoading = false;

});

} else {

await signInWithGoogle();

}

}

Future<Null> signInWithGoogle() async {

// if (googleAccount == null) {

// // Start the sign-in process:

// googleAccount = await googleSignIn.signIn();

// }

await googleSignIn.signIn();

FirebaseUser firebaseUser = await signIntoFirebase();

52

state.user = firebaseUser; // new

setState(() {

state.isLoading = false;

state.user = firebaseUser;

});

}

Future<Null> logOut() async {

FirebaseAuth.instance.signOut().then((onValue){

setState(() {

googleSignIn.signOut();

state.user=null;

});

});

}

@override

Widget build(BuildContext context) {

return new _StateDataWidget(

data: this,

child: widget.child,

);

}

}

class _StateDataWidget extends InheritedWidget {

final _StateWidgetState data;

_StateDataWidget({

Key key,

@required Widget child,

@required this.data,

}) : super(key: key, child: child);

// Rebuild the widgets that inherit from this widget

// on every rebuild of _StateDataWidget:

@override

bool updateShouldNotify(_StateDataWidget old) => true;

}

K. Google Service J-Son

{

"project_info": {

"project_number": "123333231694",

"firebase_url": "https://testing1-3195b.firebaseio.com",

"project_id": "testing1-3195b",

"storage_bucket": "testing1-3195b.appspot.com"

},

"client": [

53

{

"client_info": {

"mobilesdk_app_id": "1:123333231694:android:26ae5ea37e9b70a8",

"android_client_info": {

"package_name": "com.example.go_course"

}

},

"oauth_client": [

{

"client_id": "123333231694-

o0q1srpmis8iakar2enfdt306huk8386.apps.googleusercontent.com",

"client_type": 1,

"android_info": {

"package_name": "com.example.go_course",

"certificate_hash":

"eee44865688e7a5be04e8ab2cccf823794962f0b"

}

},

{

"client_id": "123333231694-

leqo3cne8da4n4rdf4t177aruc5m73c6.apps.googleusercontent.com",

"client_type": 3

}

],

"api_key": [

{

"current_key": "AIzaSyAi7qmIBO5mVNhpDLiHx-

EPMWi3Kn4SynA"

}

],

"services": {

"appinvite_service": {

"other_platform_oauth_client": [

{

"client_id": "123333231694-

leqo3cne8da4n4rdf4t177aruc5m73c6.apps.googleusercontent.com",

"client_type": 3

}

]

}

}

}

],

"configuration_version": "1"

}

L. Authentication

import 'package:google_sign_in/google_sign_in.dart';

import 'package:firebase_auth/firebase_auth.dart';

54

Future<GoogleSignInAccount> getSignedInAccount(

GoogleSignIn googleSignIn) async {

GoogleSignInAccount account = googleSignIn.currentUser;

if (account == null) {

account = await googleSignIn.signInSilently();

}

return account;

}

final GoogleSignIn _googleSignIn = GoogleSignIn();

final FirebaseAuth _auth = FirebaseAuth.instance;

Future<FirebaseUser> signIntoFirebase() async {

final GoogleSignInAccount googleUser = await _googleSignIn.signIn();

final GoogleSignInAuthentication googleAuth = await

googleUser.authentication;

final AuthCredential credential = GoogleAuthProvider.getCredential(

accessToken: googleAuth.accessToken,

idToken: googleAuth.idToken,

);

final FirebaseUser user = await _auth.signInWithCredential(credential);

print("signed in " + user.displayName);

return user;

}

// Future<FirebaseUser> signIntoFirebase(

// GoogleSignInAccount googleSignInAccount) async {

// FirebaseAuth _auth = FirebaseAuth.instance;

// GoogleSignInAuthentication googleAuth =

// await googleSignInAccount.authentication;

// print(googleAuth.accessToken);

// return await _auth.signInWithGoogle(

// accessToken: googleAuth.accessToken,

// idToken: googleAuth.idToken,

// );

// }

M. DETAIL KOST

import 'package:cloud_firestore/cloud_firestore.dart';

import 'package:flutter/material.dart';

import 'package:go_course/screen/profil.dart';

class DetailKos extends StatefulWidget {

@override

_DetailKosState createState() => _DetailKosState();

55

}

class _DetailKosState extends State<DetailKos> {

@override

Widget build(BuildContext context) {

return Scaffold(

appBar: AppBar(

backgroundColor: Colors.orange,

title: Text("Kos dan Camp"),

leading: new Icon(Icons.backup),

),

);

}

}

class DetailKosScreen extends StatelessWidget {

@override

Widget build(BuildContext context) {

return Scaffold(

);

}

}

N. RESTART

import 'package:flutter/material.dart';

class AppBuilder extends StatefulWidget {

final Function(BuildContext) builder;

const AppBuilder(

{Key key, this.builder})

: super(key: key);

@override

AppBuilderState createState() => new AppBuilderState();

static AppBuilderState of(BuildContext context) {

return context.ancestorStateOfType(const

TypeMatcher<AppBuilderState>());

}

}

class AppBuilderState extends State<AppBuilder> {

@override

Widget build(BuildContext context) {

return widget.builder(context);

}

56

void rebuild() {

setState(() {});

}

}

O. BUILD GRADLE

buildscript {

repositories {

google()

jcenter()

}

dependencies {

classpath 'com.android.tools.build:gradle:3.2.1'

classpath 'com.google.gms:google-services:4.2.0'

}

}

allprojects {

repositories {

google()

jcenter()

}

}

rootProject.buildDir = '../build'

subprojects {

project.buildDir = "${rootProject.buildDir}/${project.name}"

}

subprojects {

project.evaluationDependsOn(':app')

}

task clean(type: Delete) {

delete rootProject.buildDir

}

P. APP

import 'package:flutter/material.dart';

import 'package:go_course/screen/home.dart';

import 'package:go_course/screen/login.dart';

import 'package:go_course/setting/restart.dart';

class MyApp extends StatelessWidget {

@override

Widget build(BuildContext context) {

return MaterialApp(

title: 'GoogleSignIn',

57

debugShowCheckedModeBanner: false,

routes: {

'/': (context) => HomeScreen(),

'/login': (context) => LoginScreen(),

},

);

}

}

Q. SEARCH

import 'package:flutter/material.dart';

class Pencarian extends StatefulWidget {

@override

_PencarianState createState() => _PencarianState();

}

class _PencarianState extends State<Pencarian> {

@override

Widget build(BuildContext context) {

return Scaffold(

appBar: AppBar(

title: Text("data"),

),

);

}

}

R. TENTANG

import 'package:flutter/material.dart';

class About extends StatefulWidget {

@override

_AboutState createState() => _AboutState();

}

class _AboutState extends State<About> {

@override

Widget build(BuildContext context) {

return Scaffold(

appBar: AppBar(

title: Text("Tentang Apikasi"),

),

);

}

}

S. SEARCH SERVICE

import 'package:cloud_firestore/cloud_firestore.dart';

58

class SerachService {

searchByName(String searchField){

return Firestore.instance.collection("kursusan_data")

.where("nama_kursus", isGreaterThan: searchField

.substring(0, 1).toUpperCase()).getDocuments();

}

}

T. MAIN

import 'package:flutter/material.dart';

import 'package:go_course/setting/app.dart';

import 'package:go_course/setting/state_widget.dart';

void main(){

StateWidget stateWidget = new StateWidget(child:new MyApp());

runApp(stateWidget);

}

U. STATE

import 'package:firebase_auth/firebase_auth.dart';

class StateModel {

bool isLoading;

FirebaseUser user;

StateModel({

this.isLoading = false,

this.user,

});

}