Advertisement
Sebuahhobi98

dinamis_flutter

May 21st, 2022
1,608
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 4.33 KB | None | 0 0
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter_switch/flutter_switch.dart';
  3. import 'package:smart_relay/theme.dart';
  4. import 'package:flutter/material.dart';
  5. import 'package:flutter_alarm_clock/flutter_alarm_clock.dart';
  6.  
  7. class HomePage extends StatefulWidget {
  8.   @override
  9.   State<HomePage> createState() => _HomePageState();
  10. }
  11.  
  12. class _HomePageState extends State<HomePage> {
  13.   bool status = false;
  14.  
  15.   @override
  16.   Widget build(BuildContext context) {
  17.     Widget header() {
  18.       return Container(
  19.         margin: EdgeInsets.only(
  20.           top: defaultMargin,
  21.           left: defaultMargin,
  22.           right: defaultMargin,
  23.         ),
  24.         decoration: BoxDecoration(
  25.           border: Border.all(
  26.             color: Color(0xfffa4205),
  27.           ),
  28.           borderRadius: BorderRadius.all(Radius.circular(20)),
  29.         ),
  30.         child: Row(
  31.           children: [
  32.             Expanded(
  33.               child: Column(
  34.                 crossAxisAlignment: CrossAxisAlignment.start,
  35.                 children: [
  36.                   Text(
  37.                     'Smart Relay',
  38.                     style: primaryTextStyle.copyWith(
  39.                       fontSize: 24,
  40.                       fontWeight: semiBold,
  41.                     ),
  42.                   ),
  43.                   Text(
  44.                     '@sebuahhobi',
  45.                     style: primaryTextStyle.copyWith(
  46.                       fontSize: 16,
  47.                     ),
  48.                   )
  49.                 ],
  50.               ),
  51.             ),
  52.             Container(
  53.               width: 54,
  54.               height: 54,
  55.               decoration: BoxDecoration(
  56.                 shape: BoxShape.circle,
  57.                 image: DecorationImage(
  58.                   image: AssetImage('assets/sebuahhobi.png'),
  59.                 ),
  60.               ),
  61.             )
  62.           ],
  63.         ),
  64.       );
  65.     }
  66.  
  67.     Widget header2() {
  68.       return Container(
  69.         width: 200,
  70.         height: 250,
  71.         decoration: const BoxDecoration(
  72.           borderRadius: BorderRadius.only(
  73.             topLeft: Radius.circular(0),
  74.             topRight: Radius.circular(0),
  75.             bottomLeft: Radius.circular(40),
  76.             bottomRight: Radius.circular(40),
  77.           ),
  78.           color: Color(0xff39e0fa),
  79.         ),
  80.         child: Row(
  81.           children: [
  82.             Image.asset(
  83.               'assets/smart_relay.png',
  84.               width: 200,
  85.               height: 125,
  86.               fit: BoxFit.contain,
  87.             ),
  88.             Text(
  89.               'COurt VISON',
  90.               style: blackTextStyle.copyWith(
  91.                 fontSize: 18,
  92.                 fontWeight: semiBold,
  93.               ),
  94.               overflow: TextOverflow.ellipsis,
  95.             ),
  96.           ],
  97.         ),
  98.       );
  99.     }
  100.  
  101.     Widget switchs(nama, id) {
  102.       return Row(
  103.         children: <Widget>[
  104.           Text(
  105.             nama,
  106.             style: primaryTextStyle.copyWith(
  107.               fontSize: 24,
  108.               fontWeight: semiBold,
  109.             ),
  110.           ),
  111.           const SizedBox(
  112.             width: 20,
  113.           ),
  114.           FlutterSwitch(
  115.             width: 125.0,
  116.             height: 55.0,
  117.             valueFontSize: 25.0,
  118.             toggleSize: 45.0,
  119.             value: status,
  120.             borderRadius: 30.0,
  121.             padding: 8.0,
  122.             showOnOff: true,
  123.             onToggle: (val) {
  124.               setState(() {
  125.                 status = val;
  126.               });
  127.             },
  128.           ),
  129.         ],
  130.       );
  131.     }
  132.  
  133.     Widget switch_generator() {
  134.       return Container(
  135.         child: Row(
  136.           children: [
  137.             Column(
  138.               children: [
  139.                 Row(
  140.                   children: [
  141.                     Column(
  142.                       children: [
  143.                         switchs("Relay 1", 1),
  144.                         const SizedBox(
  145.                           height: 20,
  146.                         ),
  147.                         switchs("Relay 2", 1),
  148.                         switchs("Relay 1", 1),
  149.                         switchs("Relay 2", 1),
  150.                       ],
  151.                     ),
  152.                   ],
  153.                 ),
  154.               ],
  155.             ),
  156.           ],
  157.         ),
  158.       );
  159.     }
  160.  
  161.     return ListView(children: [
  162.       header2(),
  163.       switch_generator(),
  164.     ]);
  165.   }
  166. }
  167.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement