Advertisement
ngekoding

PageView

Aug 12th, 2018
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 4.21 KB | None | 0 0
  1. import 'dart:async';
  2.  
  3. import 'package:flutter/material.dart';
  4. import 'package:intl/intl.dart';
  5.  
  6. class EvaluationPage extends StatefulWidget {
  7.   @override
  8.   EvaluationPageState createState() => EvaluationPageState();
  9. }
  10.  
  11. class EvaluationPageState extends State<EvaluationPage>
  12.     with SingleTickerProviderStateMixin {
  13.   List<Map<String, String>> _jenis_struktur_list = [
  14.     {'title': 'Kayu', 'value': 'kayu'},
  15.     {'title': 'Tembok', 'value': 'tembok'},
  16.     {'title': 'Beton', 'value': 'beton'},
  17.     {'title': 'Baja', 'value': 'baja'},
  18.     {'title': 'Lainnya', 'value': 'lainnya'},
  19.   ];
  20.   String _jenis_struktur = 'kayu';
  21.  
  22.   final dateFormat = DateFormat('dd/MM/yyyy');
  23.   DateTime _date = DateTime.now();
  24.   TimeOfDay _time = TimeOfDay.now();
  25.  
  26.   TextEditingController _tanggalController =
  27.       new TextEditingController(text: 'Coba');
  28.  
  29.   TabController tabController;
  30.   PageController pageController;
  31.  
  32.   @override
  33.   void initState() {
  34.     super.initState();
  35.     tabController = new TabController(length: 2, vsync: this);
  36.   }
  37.  
  38.   @override
  39.   void dispose() {
  40.     super.dispose();
  41.     tabController.dispose();
  42.   }
  43.  
  44.   @override
  45.   Widget build(BuildContext context) {
  46.     final pageWidth = MediaQuery.of(context).size.width - 32.0;
  47.     return Scaffold(
  48.         appBar: AppBar(
  49.           leading: InkWell(
  50.             child: Icon(Icons.arrow_back),
  51.             onTap: () => Navigator.pop(context),
  52.           ),
  53.           title: Text('Formulir'),
  54.         ),
  55.         body: Padding(
  56.           padding: const EdgeInsets.all(16.0),
  57.           child: Column(
  58.             children: [
  59.               Padding(
  60.                 padding: const EdgeInsets.all(16.0),
  61.                 child: Text('1 of 4'),
  62.               ),
  63.               Expanded(
  64.                 child: PageView(
  65.                   children: <Widget>[
  66.                     Container(
  67.                       padding: EdgeInsets.all(16.0),
  68.                       width: pageWidth,
  69.                       color: Colors.white,
  70.                       child: Center(
  71.                         child: Text('Content 1'),
  72.                       ),
  73.                     ),
  74.                     Container(
  75.                       padding: EdgeInsets.all(16.0),
  76.                       width: pageWidth,
  77.                       color: Colors.yellow,
  78.                       child: Center(
  79.                         child: Text('Content 2'),
  80.                       ),
  81.                     ),
  82.                     Container(
  83.                       padding: EdgeInsets.all(16.0),
  84.                       width: pageWidth,
  85.                       color: Colors.white,
  86.                       child: Center(
  87.                         child: Text('Content 3'),
  88.                       ),
  89.                     ),
  90.                   ],
  91.                 ),
  92.               ),
  93.               Padding(
  94.                 padding: const EdgeInsets.all(16.0),
  95.                 child: Row(
  96.                   mainAxisAlignment: MainAxisAlignment.spaceBetween,
  97.                   children: <Widget>[
  98.                     FloatingActionButton(
  99.                       mini: true,
  100.                       child: Icon(Icons.arrow_back),
  101.                       onPressed: () {},
  102.                     ),
  103.                     FloatingActionButton(
  104.                       mini: true,
  105.                       child: Icon(Icons.arrow_forward),
  106.                       onPressed: () {},
  107.                     ),
  108.                   ],
  109.                 ),
  110.               )
  111.             ],
  112.           ),
  113.         ));
  114.   }
  115.  
  116.   Future<Null> _selectDate(BuildContext context) async {
  117.     final DateTime picked = await showDatePicker(
  118.         context: context,
  119.         initialDate: _date,
  120.         firstDate: DateTime(_date.year),
  121.         lastDate: DateTime(2019));
  122.     if (picked != null && picked != _date) {
  123.       setState(() {
  124.         _date = picked;
  125.       });
  126.       print('Result: ' + dateFormat.format(_date));
  127.     }
  128.   }
  129.  
  130.   sectionTitle(String title) {
  131.     return Container(
  132.       margin: EdgeInsets.only(top: 16.0, bottom: 16.0, left: 2.0),
  133.       child: Text(
  134.         title,
  135.         style: TextStyle(
  136.           fontSize: 16.0,
  137.           fontWeight: FontWeight.w300,
  138.           color: Colors.black54,
  139.         ),
  140.       ),
  141.     );
  142.   }
  143. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement