dtb_link 0.0.7+8 copy "dtb_link: ^0.0.7+8" to clipboard
dtb_link: ^0.0.7+8 copied to clipboard

Dtb link

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:percent_indicator/circular_percent_indicator.dart';
import 'config_page.dart';
import 'dtb_helper.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addPostFrameCallback((_) {
      debugPrint("initPlatformState");
      service.initOnEvent();
      initPlatformState();
    });
  }

  Future<void> initPlatformState() async {

    String platformVersion;
    try {
      debugPrint("platformVersion before");
      platformVersion = await service.dtbLink.getPlatformVersion() ?? 'Unknown platform version';
      debugPrint("platformVersion: $platformVersion");
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }
    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  @override
  Widget build(BuildContext context) {
    return GetMaterialApp(
      theme: ThemeData(
      brightness: Brightness.dark,
      appBarTheme: const AppBarTheme(
        systemOverlayStyle: SystemUiOverlayStyle(statusBarBrightness: Brightness.dark),
        backgroundColor: Colors.transparent,
        centerTitle: false,
        titleSpacing: 10,
        elevation: 0,
      ),
      primaryColor: color20,
      scaffoldBackgroundColor: color01,
    ),
      // home: Scaffold(
      //   appBar: AppBar(
      //     title: const Text('DtbLink example app'),
      //   ),
      //   body: Center(
      //     child: Text('PlatformVersion: $_platformVersion\n'),
      //   ),
      // ),
      home: Scaffold(
        appBar: AppBar(title: Text("D135 Link Flutter Demo $_platformVersion")),
        body: Column(
          children: [
            _buildConfig(),
            // _buildEasyTransaction(context
            //     .watch<DemoProvider>()
            //     .initData),
            // _buildTranHistory(),
          ],
        ),
      ),
    );
  }

  Widget _buildConfig() {
    return Container(
      decoration: const BoxDecoration(
        color: color02,
        borderRadius: BorderRadius.only(bottomLeft: Radius.circular(20), bottomRight: Radius.circular(20)),
        image: DecorationImage(
          image: AssetImage("assets/home_section_bg.png"),
          fit: BoxFit.fitWidth,
        ),
      ),
      child: Padding(
        padding: const EdgeInsets.all(16),
        child: Row(
          children: [
            Expanded(
              child: Column(
                children: [
                  buildDeviceInfo(),
            //       _buildTerminalInfo(
            //         context
            //             .watch<DemoProvider>()
            //             .terminalConfigPercent,
            //         context
            //             .watch<DemoProvider>()
            //             .terminalConfigTitle,
            //       ),
                  const SizedBox(height: 16),
                  ElevatedButton(
                    onPressed: () => Get.to(const ConfigPage()),
                    style: ElevatedButton.styleFrom(
                      shape: const StadiumBorder(),
                      backgroundColor: color20,
                      side: const BorderSide(color: color03, width: 3),
                    ),
                    child: const Row(
                      mainAxisAlignment: MainAxisAlignment.center,
                      mainAxisSize: MainAxisSize.max,
                      children: [
                        Text('Тохиргоо'),
                        Icon(Icons.chevron_right),
                      ],
                    ),
                  ),
                ],
              ),
            ),
            const SizedBox(width: 16),
            CircularPercentIndicator(
              radius: 80,
              lineWidth: 6,
              animation: true,
              percent: 0.755,
              startAngle: 180,
              backgroundColor: color03,
              animationDuration: 2000,
              center: Container(
                height: 138,
                width: 138,
                decoration: const BoxDecoration(shape: BoxShape.circle, color: color01),
                child: Center(
                  child: Container(
                    height: 126,
                    width: 126,
                    decoration: const BoxDecoration(shape: BoxShape.circle, color: color04),
                    child: const Column(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: [
                        Text("Тохиргоо"),
                        Text(
                          "42.31%",
                          style: TextStyle(fontWeight: FontWeight.bold),
                        ),
                        Text(
                          "-42,aa",
                          style: TextStyle(color: color11),
                        ),
                      ],
                    ),
                  ),
                ),
              ),
              circularStrokeCap: CircularStrokeCap.round,
              progressColor: color20,
            ),
          ],
        ),
      ),
    );
  }

  // Widget _buildEasyTransaction(DataInitRet? initData) {
  //   return Container(
  //     margin: const EdgeInsets.all(10),
  //     padding: const EdgeInsets.only(left: 10, right: 10, top: 20, bottom: 20),
  //     decoration: const BoxDecoration(
  //       color: color02,
  //       borderRadius: BorderRadius.all(Radius.circular(20)),
  //     ),
  //     child: Column(
  //       children: [
  //         const Row(
  //           mainAxisSize: MainAxisSize.max,
  //           mainAxisAlignment: MainAxisAlignment.spaceBetween,
  //           children: [
  //             Text("Хялбар Гүйлгээ"),
  //             Icon(Icons.edit_note, color: color05),
  //           ],
  //         ),
  //         const SizedBox(height: 20),
  //         LayoutBuilder(builder: (context, constraint) {
  //           double width = constraint.maxWidth / 4 - 6;
  //           Size size = Size(width, width);
  //           return Row(
  //             mainAxisAlignment: MainAxisAlignment.spaceBetween,
  //             children: [
  //               EasyButton(
  //                 size: size,
  //                 onPressed: initData != null ? () => _onAddLog(EasyKey.sKey, data: initData) : null,
  //                 child: const Text("SKey"),
  //               ),
  //               EasyButton(
  //                 size: size,
  //                 onPressed: initData != null ? () => _onAddLog(EasyKey.echo, data: initData) : null,
  //                 child: const Text("Echo"),
  //               ),
  //               EasyButton(
  //                 size: size,
  //                 onPressed: initData != null ? () => _onAddLog(EasyKey.saleTran, data: initData) : null,
  //                 child: const Text("Sale"),
  //               ),
  //               EasyButton(
  //                 size: size,
  //                 child: const Text("Void"),
  //               ),
  //             ],
  //           );
  //         })
  //       ],
  //     ),
  //   );
  // }
}