SHARE
TWEET

Untitled

a guest Dec 8th, 2019 95 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import 'package:flutter/material.dart';
  2. import 'dart:async';
  3. import 'dart:convert';
  4. import 'package:http/http.dart' as http;
  5. import 'package:wisata_flutter/model/ModelSlider.dart';
  6. import 'package:wisata_flutter/constant/Constant.dart';
  7. import 'package:carousel_pro/carousel_pro.dart';
  8.  
  9. class HomePage extends StatefulWidget {
  10.   @override
  11.   _HomePageState createState() => _HomePageState();
  12. }
  13.  
  14. class _HomePageState extends State<HomePage> {
  15.   //List data slider
  16.   static List listSlider = [];
  17.   Map data;
  18.  
  19.   //get data slider from server
  20.   Future getDataSlider() async {
  21.     http.Response response =
  22.         await http.get(ConstantFile().baseUrl + "getSlider");
  23.     data = jsonDecode(response.body);
  24.     if (response.statusCode == 200) {
  25.       setState(() {
  26.         listSlider = data['data'];
  27.         print(listSlider);
  28.       });
  29.     }
  30.   }
  31.  
  32.   @override
  33.   void initState() {
  34.     // TODO: implement initState
  35.     super.initState();
  36.     getDataSlider();
  37.   }
  38.  
  39.   Widget image_slider() {
  40.     return Container(
  41.       height: 250.0,
  42.       child: Padding(
  43.         padding: const EdgeInsets.all(2.0),
  44.         child: Card(
  45.           shape:
  46.               RoundedRectangleBorder(borderRadius: BorderRadius.circular(15.0)),
  47.           child: Padding(
  48.             padding: const EdgeInsets.all(5.0),
  49.             child: new Carousel(
  50.               images: [
  51.                 NetworkImage(
  52.                     "http://onedayflutter.e-iso27001.com/images/gudeg%20yogyakarta.jpg"),
  53.                 NetworkImage("${ConstantFile().pathImage}" +
  54.                     "${listSlider[0]['foto_wisata']}"),
  55.                 NetworkImage("${ConstantFile().pathImage}" +
  56.                     "${listSlider[1]['foto_wisata']}"),
  57.                 NetworkImage("${ConstantFile().pathImage}" +
  58.                     "${listSlider[2]['foto_wisata']}"),
  59.               ],
  60.               animationCurve: Curves.fastOutSlowIn,
  61.               animationDuration: new Duration(microseconds: 2000),
  62.             ),
  63.           ),
  64.         ),
  65.       ),
  66.     );
  67.   }
  68.  
  69.   //menampilkan slider dengan corousal
  70. //  var imageSlider = Container(
  71. //    height: 185,
  72. //    child: listSlider.isEmpty ? CircularProgressIndicator(strokeWidth: 25,)
  73. //    : new SizedBox(
  74. //      height: 150.0,
  75. //      width: 300.0,
  76. //      child: Carousel(
  77. //        images: [
  78. //          //menampilkan slider
  79. //
  80. //          NetworkImage("http://onedayflutter.e-iso27001.com/images/gudeg%20yogyakarta.jpg"),
  81. //          NetworkImage("${ConstantFile().pathImage}"+ "${listSlider[0]['foto_wisata']}"),
  82. //          NetworkImage("${ConstantFile().pathImage}"+ "${listSlider[1]['foto_wisata']}"),
  83. //          NetworkImage("${ConstantFile().pathImage}"+ "${listSlider[2]['foto_wisata']}"),
  84. //        ],
  85. //        dotSize: 4.0,
  86. //        dotSpacing: 15.0,
  87. //        dotColor: Colors.lightBlueAccent,
  88. //        indicatorBgPadding: 5.0,
  89. //        dotBgColor: Colors.black12.withOpacity(0.5),
  90. //        borderRadius: true,
  91. //        moveIndicatorFromBottom: 180,
  92. //        noRadiusForIndicator: true,
  93. //      ),
  94. //
  95. //    )
  96. //  );
  97.   @override
  98.   Widget build(BuildContext context) {
  99.     return Scaffold(
  100.       body: Stack(
  101.         children: <Widget>[
  102.           SingleChildScrollView(
  103.             child: Column(
  104.               children: <Widget>[image_slider()],
  105.             ),
  106.           )
  107.         ],
  108.       ),
  109.     );
  110.   }
  111. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top