Advertisement
Guest User

Untitled

a guest
Jan 21st, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 5.15 KB | None | 0 0
  1. import 'package:admindonordarah/src/kecocokandarah/golABmin.dart';
  2. import 'package:admindonordarah/src/kecocokandarah/golABplus.dart';
  3. import 'package:admindonordarah/src/kecocokandarah/golAmin.dart';
  4. import 'package:admindonordarah/src/kecocokandarah/golAplus.dart';
  5. import 'package:admindonordarah/src/kecocokandarah/golBmin.dart';
  6. import 'package:admindonordarah/src/kecocokandarah/golBplus.dart';
  7. import 'package:admindonordarah/src/kecocokandarah/golOmin.dart';
  8. import 'package:admindonordarah/src/kecocokandarah/golOplus.dart';
  9. import 'package:flutter/material.dart';
  10.  
  11. class KecocokanDarahPage extends StatefulWidget {
  12.   @override
  13.   _KecocokanDarahPageState createState() => _KecocokanDarahPageState();
  14. }
  15.  
  16. class _KecocokanDarahPageState extends State<KecocokanDarahPage> {
  17.   String golDarah;
  18.  
  19.   List<DropdownMenuItem<String>> golDarahItems = [
  20.     new DropdownMenuItem(
  21.       child: Text("A-"),
  22.       value: "A-",
  23.     ),
  24.     new DropdownMenuItem(
  25.       child: Text("A+"),
  26.       value: "A+",
  27.     ),
  28.     new DropdownMenuItem(
  29.       child: Text("AB-"),
  30.       value: "AB-",
  31.     ),
  32.     new DropdownMenuItem(
  33.       child: Text("AB+"),
  34.       value: "AB+",
  35.     ),
  36.     new DropdownMenuItem(
  37.       child: Text("B-"),
  38.       value: "B-",
  39.     ),
  40.     new DropdownMenuItem(
  41.       child: Text("B+"),
  42.       value: "B+",
  43.     ),
  44.     new DropdownMenuItem(
  45.       child: Text("O-"),
  46.       value: "O-",
  47.     ),
  48.     new DropdownMenuItem(
  49.       child: Text("O+"),
  50.       value: "O+",
  51.     ),
  52.   ];
  53.   @override
  54.   Widget build(BuildContext context) {
  55.     return Scaffold(
  56.       appBar: AppBar(
  57.         title: Text('Kecocokan Darah', style: TextStyle(color: Colors.white)),
  58.       ),
  59.       body: Center(
  60.         child: Container(
  61.           child: Column(
  62.             children: <Widget>[
  63.               SizedBox(height: 50),
  64.               Text(
  65.                 'Apa jenis darah anda ?',
  66.                 style: TextStyle(
  67.                   fontSize: 20,
  68.                 ),
  69.               ),
  70.               ListTile(
  71.                 leading: Image.asset(
  72.                   'assets/images/blood.png',
  73.                   width: 30,
  74.                   height: 30,
  75.                 ),
  76.                 title: DropdownButton(
  77.                   items: golDarahItems,
  78.                   hint: Text("Golongan Darah"),
  79.                   value: golDarah,
  80.                   onChanged: (val) {
  81.                     setState(() {
  82.                       golDarah = val;
  83.                     });
  84.                   },
  85.                 ),
  86.               ),
  87.               RaisedButton(
  88.                 color: Colors.redAccent,
  89.                 child: SizedBox(
  90.                   width: 100,
  91.                   height: 50,
  92.                   child: Center(
  93.                       child: Text(
  94.                     'Cari',
  95.                     style: TextStyle(
  96.                       color: Colors.white,
  97.                     ),
  98.                   )),
  99.                 ),
  100.                 onPressed: () {
  101.                   if (golDarah == 'A-') {
  102.                     Navigator.push(
  103.                       context,
  104.                       MaterialPageRoute(
  105.                           builder: (BuildContext context) => GolDarahAmin()),
  106.                     );
  107.                   } else if (golDarah == 'A+') {
  108.                     Navigator.push(
  109.                       context,
  110.                       MaterialPageRoute(
  111.                           builder: (BuildContext context) => GolDarahAPlus()),
  112.                     );
  113.                   } else if (golDarah == 'AB-') {
  114.                     Navigator.push(
  115.                       context,
  116.                       MaterialPageRoute(
  117.                           builder: (BuildContext context) => GolDarahABmin()),
  118.                     );
  119.                   } else if (golDarah == 'AB+') {
  120.                     Navigator.push(
  121.                       context,
  122.                       MaterialPageRoute(
  123.                           builder: (BuildContext context) => GolDarahABPlus()),
  124.                     );
  125.                   } else if (golDarah == 'O-') {
  126.                     Navigator.push(
  127.                       context,
  128.                       MaterialPageRoute(
  129.                           builder: (BuildContext context) => GolDarahOmin()),
  130.                     );
  131.                   } else if (golDarah == 'O+') {
  132.                     Navigator.push(
  133.                       context,
  134.                       MaterialPageRoute(
  135.                           builder: (BuildContext context) => GolDarahOPlus()),
  136.                     );
  137.                   } else if (golDarah == 'B-') {
  138.                     Navigator.push(
  139.                       context,
  140.                       MaterialPageRoute(
  141.                           builder: (BuildContext context) => GolDarahBmin()),
  142.                     );
  143.                   } else if (golDarah == 'B+') {
  144.                     Navigator.push(
  145.                       context,
  146.                       MaterialPageRoute(
  147.                           builder: (BuildContext context) => GolDarahBplus()),
  148.                     );
  149.                   }
  150.                 },
  151.               )
  152.             ],
  153.           ),
  154.         ),
  155.       ),
  156.     );
  157.   }
  158. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement