Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Mobile Go-Wisata
Go-Wisata-Mobile
Commits
e28934bc
Commit
e28934bc
authored
2 years ago
by
vpriansyah
Browse files
Options
Download
Email Patches
Plain Diff
Delete cafe.dart
parent
b2503d8d
main
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/user/cafe.dart
+0
-199
lib/user/cafe.dart
with
0 additions
and
199 deletions
+0
-199
lib/user/cafe.dart
deleted
100644 → 0
View file @
b2503d8d
import
'package:desa_wisata/models/cart.dart'
;
import
'package:desa_wisata/theme.dart'
;
import
'dart:collection'
;
import
'dart:convert'
;
import
'package:flutter/material.dart'
;
import
'package:http/http.dart'
as
http
;
import
'../main.dart'
;
import
'package:auto_size_text/auto_size_text.dart'
;
import
'package:flutter/material.dart'
;
import
'package:font_awesome_flutter/font_awesome_flutter.dart'
;
import
'package:google_fonts/google_fonts.dart'
;
class
Cafe
extends
StatefulWidget
{
const
Cafe
({
Key
?
key
})
:
super
(
key:
key
);
@override
State
<
Cafe
>
createState
()
=>
CafeState
();
}
class
CafeState
extends
State
<
Cafe
>
{
@override
Widget
build
(
BuildContext
context
)
{
return
Scaffold
(
appBar:
AppBar
(
backgroundColor:
Color
(
0xFFFCC050
),
automaticallyImplyLeading:
false
,
leading:
IconButton
(
icon:
Icon
(
Icons
.
arrow_back_rounded
,
color:
Colors
.
white
,
size:
30
,
),
onPressed:
()
async
{
Navigator
.
pop
(
context
);
},
),
title:
Text
(
'Daftar Cafe'
,
),
actions:
[],
centerTitle:
false
,
elevation:
2
,
),
body:
FutureBuilder
(
future:
getWisata
(),
builder:
(
context
,
AsyncSnapshot
snapshot
)
{
if
(
snapshot
.
hasData
)
{
print
(
'snapshot:'
+
snapshot
.
data
.
length
.
toString
());
return
ListView
.
builder
(
itemBuilder:
(
context
,
index
)
{
// final List place = fetch();
return
InkWell
(
onTap:
()
{
var
get
=
fetch
();
get
.
then
((
value
)
{
final
snackBar
=
SnackBar
(
content:
Text
(
snapshot
.
data
[
index
][
'name'
]
+
' added to cart'
),
);
setState
(()
{
Cart
c1
=
Cart
(
id:
snapshot
.
data
[
index
][
'id'
],
idtempat:
snapshot
.
data
[
index
][
'id'
],
nama:
snapshot
.
data
[
index
][
'name'
],
kategori:
'lainnya'
,
qty:
1
,
harga:
int
.
parse
(
snapshot
.
data
[
index
][
'harga'
],
),
image:
snapshot
.
data
[
index
][
'image'
],
);
cartList
.
add
(
c1
);
ScaffoldMessenger
.
of
(
context
)
.
showSnackBar
(
snackBar
);
});
});
},
child:
Card
(
child:
Row
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
children:
<
Widget
>[
Expanded
(
flex:
1
,
child:
ClipRRect
(
borderRadius:
BorderRadius
.
circular
(
24
),
child:
SizedBox
.
fromSize
(
size:
Size
.
fromRadius
(
38
),
// Image radius
child:
Image
.
network
(
baseUrl
+
'images/'
+
snapshot
.
data
[
index
][
'image'
],
fit:
BoxFit
.
cover
,
loadingBuilder:
(
BuildContext
context
,
Widget
child
,
ImageChunkEvent
?
loadingProgress
)
{
if
(
loadingProgress
==
null
)
return
child
;
return
Center
(
child:
CircularProgressIndicator
(
value:
loadingProgress
.
expectedTotalBytes
!=
null
?
loadingProgress
.
cumulativeBytesLoaded
/
loadingProgress
.
expectedTotalBytes
!
:
null
,
),
);
},
),
),
),
),
Expanded
(
flex:
3
,
child:
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
Column
(
crossAxisAlignment:
CrossAxisAlignment
.
start
,
mainAxisSize:
MainAxisSize
.
min
,
children:
<
Widget
>[
Text
(
snapshot
.
data
[
index
][
'name'
],
style:
title3
.
copyWith
(
color:
Color
(
0xFF101213
),
),
),
AutoSizeText
(
snapshot
.
data
[
index
][
'deskripsi'
],
style:
GoogleFonts
.
montserrat
(
fontWeight:
FontWeight
.
normal
,
),
),
Padding
(
padding:
EdgeInsetsDirectional
.
fromSTEB
(
0
,
0
,
0
,
3
),
child:
Text
(
snapshot
.
data
[
index
][
'alamat'
],
style:
GoogleFonts
.
montserrat
(
color:
Color
(
0xFFFCC050
),
fontSize:
16
,
),
),
),
Padding
(
padding:
EdgeInsetsDirectional
.
fromSTEB
(
0
,
0
,
0
,
3
),
child:
Text
(
''
,
// snapshot.data[index]['deskripsi_harga'],
style:
GoogleFonts
.
montserrat
(
color:
Color
(
0xFFFCC050
),
fontSize:
16
,
),
),
),
],
),
),
),
],
),
elevation:
3
,
margin:
EdgeInsets
.
all
(
10
),
),
);
},
itemCount:
snapshot
.
data
.
length
,
);
// This trailing comma makes auto-formatting nicer for build methods.
}
else
{
return
Center
(
child:
CircularProgressIndicator
(),
);
}
// return Text('Data Error');
}));
}
final
String
baseUrl
=
'http://go-wisata.id/'
;
final
String
apiUrl
=
'http://go-wisata.id/api/kuliner'
;
Future
<
List
<
Map
<
String
,
dynamic
>>?>
fetch
()
async
{
http
.
Response
response
=
await
http
.
get
(
Uri
.
parse
(
"http://go-wisata.id/api/kuliner"
));
if
(
response
.
statusCode
!=
200
)
return
null
;
return
List
<
Map
<
String
,
dynamic
>>.
from
(
json
.
decode
(
response
.
body
)[
'data'
]);
}
Future
getWisata
()
async
{
var
response
=
await
http
.
get
(
Uri
.
parse
(
apiUrl
));
// print(json.decode(response.body));
return
json
.
decode
(
response
.
body
);
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help