Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 2.36 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2.  
  3. void main() => runApp(MyApp());
  4.  
  5. class MyApp extends StatefulWidget {
  6.   @override
  7.   _MyAppState createState() => _MyAppState();
  8. }
  9.  
  10. class _MyAppState extends State<MyApp> {
  11.   var usernameCtr = TextEditingController();
  12.   var passwordCtr = TextEditingController();
  13.  
  14.   int angka;
  15.  
  16.   @override
  17.   void initState() {
  18.     super.initState();
  19.     angka = int.parse(usernameCtr.text) + int.parse(passwordCtr.text);
  20.   }
  21.  
  22.   Widget build(BuildContext context) {
  23.     return MaterialApp(
  24.       home: SafeArea(
  25.           child: Scaffold(
  26.         body: SingleChildScrollView(
  27.           child: Column(children: <Widget>[
  28.             TextFormField(
  29.               controller: usernameCtr,
  30.               decoration: InputDecoration(labelText: "Username"),
  31.             ),
  32.             TextFormField(
  33.               controller: passwordCtr,
  34.               decoration: InputDecoration(labelText: "Password"),
  35.               keyboardType: TextInputType.number,
  36.             ),
  37.             const SizedBox(height: 30),
  38.             InkWell(
  39.               child: Container(
  40.                 width: 30,
  41.                 height: 30,
  42.                 decoration: BoxDecoration(
  43.                     gradient: LinearGradient(
  44.                         colors: [Color(4279757529), Color(0xFF6078ea)]),
  45.                     borderRadius: BorderRadius.circular(6.0),
  46.                     boxShadow: [
  47.                       BoxShadow(
  48.                           color: Color(0xFF6078ea).withOpacity(.3),
  49.                           offset: Offset(0.0, 8.0),
  50.                           blurRadius: 8.0)
  51.                     ]),
  52.                 child: Material(
  53.                   color: Colors.transparent,
  54.                   child: InkWell(
  55.                     onTap: () {
  56.                       print(angka);
  57.                       //teks=passwordCtr.text;
  58.                       setState(() {});
  59.                     },
  60.                     child: Center(
  61.                       child: Text("+",
  62.                           style: TextStyle(
  63.                               color: Colors.white,
  64.                               fontSize: 18,
  65.                               letterSpacing: 1.0)),
  66.                     ),
  67.                   ),
  68.                 ),
  69.               ),
  70.             ),
  71.             Text(angka.toString())
  72.           ]),
  73.         ),
  74.       )),
  75.     );
  76.   }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement