Wheemangga

UAS Pak rinto

Jun 24th, 2022
1,214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 3.62 KB | None | 0 0
  1. // Muhammad Fauzul Ashari
  2. // 41520010223
  3. // 24/06/22
  4.  
  5. import 'package:flutter/material.dart';
  6.  
  7. void main() {
  8.   runApp(
  9.     const MaterialApp(
  10.       home: Page1(),
  11.     ),
  12.   );
  13. }
  14.  
  15. class Page1 extends StatefulWidget {
  16.   const Page1({Key? key}) : super(key: key);
  17.  
  18.   _FormState createState() => _FormState();
  19. }
  20.  
  21. class _FormState extends State<Page1> {
  22.   final inputPage1 = TextEditingController();
  23.   final nim1 = TextEditingController();
  24.  
  25.   getItemAndNavigate(BuildContext context) {
  26.     Navigator.push(
  27.       context,
  28.       MaterialPageRoute(
  29.           builder: (context) =>
  30.               Page2(inputPage2: inputPage1.text, nim2: nim1.text)),
  31.     );
  32.   }
  33.  
  34.   @override
  35.   Widget build(BuildContext context) {
  36.     return Scaffold(
  37.       appBar: AppBar(
  38.         title: const Text('UAS'),
  39.       ),
  40.       body: Center(
  41.         child: Column(
  42.           children: [
  43.             Image.network(
  44.               'https://www.mercubuana.ac.id/img/logo_baru_umb.jpg',
  45.               width: 300,
  46.               height: 300,
  47.             ),
  48.             Padding(
  49.               padding: const EdgeInsets.all(20.0),
  50.               child: TextField(
  51.                 decoration: const InputDecoration(
  52.                     hintText: 'Nama Lengkap?',
  53.                     prefixIcon: Icon(Icons.people),
  54.                     labelText: 'Nama Lengkap'),
  55.                 controller: inputPage1,
  56.               ),
  57.             ),
  58.             Padding(
  59.               padding: const EdgeInsets.all(20.0),
  60.               child: TextField(
  61.                 decoration: const InputDecoration(
  62.                     hintText: 'NIM?',
  63.                     prefixIcon: Icon(Icons.lock),
  64.                     labelText: 'NIM'),
  65.                 controller: nim1, // Controller buat nyimpen text.
  66.               ),
  67.             ),
  68.             ElevatedButton(
  69.               onPressed: () => getItemAndNavigate(context),
  70.               child: const Padding(
  71.                 padding: EdgeInsets.fromLTRB(120.0, 10.0, 120.0, 10.0),
  72.                 child: Text('Masuk'),
  73.               ),
  74.             ),
  75.           ],
  76.         ),
  77.       ),
  78.     );
  79.   }
  80. }
  81.  
  82. class Page2 extends StatelessWidget {
  83.   final inputPage2;
  84.   final nim2;
  85.   const Page2({Key? key, @required this.inputPage2, this.nim2})
  86.       : super(key: key);
  87.  
  88.   @override
  89.   Widget build(BuildContext context) {
  90.     return Scaffold(
  91.       appBar: AppBar(
  92.         backgroundColor: Colors.amber,
  93.         title: Text('Konfirmasi'),
  94.       ),
  95.       body: Padding(
  96.         padding: const EdgeInsets.all(8.0),
  97.         child: Column(
  98.           // mainAxisAlignment: MainAxisAlignment.center,
  99.           crossAxisAlignment: CrossAxisAlignment.start,
  100.           children: [
  101.             const Padding(
  102.               padding: EdgeInsets.only(left: 8.0, top: 10.0),
  103.               child: Text(
  104.                 'Nama Lengkap',
  105.                 style: TextStyle(fontSize: 10.0),
  106.               ),
  107.             ),
  108.             Padding(
  109.               padding: const EdgeInsets.only(left: 8.0),
  110.               child: Text(
  111.                 '$inputPage2',
  112.                 style: TextStyle(fontSize: 18.0),
  113.               ),
  114.             ),
  115.             const Padding(
  116.               padding: EdgeInsets.only(left: 8.0, top: 10.0),
  117.               child: Text(
  118.                 'NIM',
  119.                 style: TextStyle(fontSize: 10.0),
  120.               ),
  121.             ),
  122.             Padding(
  123.               padding: const EdgeInsets.only(left: 8.0),
  124.               child: Text(
  125.                 '$nim2',
  126.                 style: TextStyle(fontSize: 18.0),
  127.               ),
  128.             )
  129.           ],
  130.         ),
  131.       ),
  132.     );
  133.   }
  134. }
  135.  
Advertisement
Add Comment
Please, Sign In to add comment