allgood_nasiya 0.0.2 copy "allgood_nasiya: ^0.0.2" to clipboard
allgood_nasiya: ^0.0.2 copied to clipboard

Flutter tool pack for allgood_nasiya active in Uzbekistan..

example/lib/main.dart

import 'dart:developer';

import 'package:allgood_nasiya/ui/widgets/input_ui/input_ui.dart';
import 'package:allgood_nasiya/ui/widgets/size_box/size_box_widget.dart';
import 'package:allgood_nasiya/utils/services/logs/snack_bar_log_extension.dart';
import 'package:allgood_nasiya/utils/services/theme/colors.dart';
import 'package:allgood_nasiya/utils/services/theme/text_style_const.dart';
import 'package:allgood_nasiya/utils/services/validations/mask_formatters.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:allgood_nasiya/allgood_nasiya.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';
  final _allgoodNasiyaPlugin = AllgoodNasiya();

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    // We also handle the message potentially returning null.
    try {
      platformVersion = await _allgoodNasiyaPlugin.getPlatformVersion() ??
          'Unknown platform version';
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: AllgoodApp(
        allgoodNasiyaPlugin: _allgoodNasiyaPlugin,
      ),
    );
  }
}

class AllgoodApp extends StatefulWidget {
  final AllgoodNasiya allgoodNasiyaPlugin;

  AllgoodApp({
    super.key,
    required this.allgoodNasiyaPlugin,
  });

  @override
  State<AllgoodApp> createState() => _AllgoodAppState();
}

class _AllgoodAppState extends State<AllgoodApp> {
  bool isLoading = false;
  TextEditingController phoneController = TextEditingController();
  TextEditingController passwordController = TextEditingController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Plugin example app'),
      ),
      body: Padding(
        padding: const EdgeInsets.all(16),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisSize: MainAxisSize.min,
          children: [
            Expanded(
              child: Column(
                mainAxisAlignment: MainAxisAlignment.start,
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  InputUI(
                    title: "User key",
                    hint: "Enter your phone number",
                    icon: "phone",
                    prefixHint: "",
                    inputFormatters: const [],
                    controller: phoneController,
                  ),
                  verticalBox(verticalSize: 16),
                  // InputUI(
                  //   title: "Password",
                  //   hint: "Enter your password",
                  //   icon: "card",
                  //   prefixHint: "",
                  //   keyboardType: TextInputType.phone,
                  //   inputFormatters: [
                  //     FilteringTextInputFormatter.digitsOnly,
                  //   ],
                  //   controller: passwordController,
                  // ),
                ],
              ),
            ),
            GestureDetector(
              onTap: isLoading
                  ? null
                  : () async {
                      final response = await Navigator.push(
                        context,
                        MaterialPageRoute(
                          builder: (context) => AllGoodNasiya(
                            userKey:
                                // "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpJVCL9.eyJzdWIiOjEzNiwidXNlcm5hbWUiOiI5OTgzMzMzMzMzMzMiLCJpYXQiOjE3MjM0MTE0NjIsImV4cCI6MTcyMzQ5Nzg2Mn0.sd0WlYJK6DfIephc_7bOOqZ1b2jwPTAP3URbC4zUD_s",
                                phoneController.text.isNotEmpty
                                    ? phoneController.text
                                    : "1e6201c8-df67-4696-943b-222d769262bb",
                            // tokenResponse.$2,
                          ),
                        ),
                      );

                      log("Application ID: $response");

                      // setState(() {
                      //   isLoading = true;
                      // });
                      //       final tokenResponse =
                      //           await widget.allgoodNasiyaPlugin.login(
                      //         phoneNumber:
                      //             "998${phoneMaskFormatter.unmaskText(phoneController.text)}",
                      //         password: passwordController.text,
                      //       );
                      //
                      //       setState(() {
                      //         isLoading = false;
                      //       });
                      //
                      //       log("Application error: $tokenResponse");
                      //
                      //       if (tokenResponse.$1) {
                      //         final response = await Navigator.push<(bool, int)?>(
                      //           context,
                      //           MaterialPageRoute(
                      //             builder: (context) => const AllGoodNasiya(
                      //               userKey:
                      //                   // "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpJVCL9.eyJzdWIiOjEzNiwidXNlcm5hbWUiOiI5OTgzMzMzMzMzMzMiLCJpYXQiOjE3MjM0MTE0NjIsImV4cCI6MTcyMzQ5Nzg2Mn0.sd0WlYJK6DfIephc_7bOOqZ1b2jwPTAP3URbC4zUD_s",
                      //                   "1e6201c8-df67-4696-943b-222d769262bd",
                      //                   // tokenResponse.$2,
                      //             ),
                      //           ),
                      //         );
                      //         log("Application ID: $response");
                      //       }else{
                      //         context.showSnackBar(
                      //           message: tokenResponse.$2,
                      //         );
                      //       }
                    },
              child: Container(
                height: 56,
                padding: const EdgeInsets.all(16),
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(16),
                  color: buttonColor,
                ),
                child: Stack(
                  alignment: Alignment.center,
                  children: [
                    Text(
                      "Get token",
                      style: TextStyleS.s18w700W(),
                      textAlign: TextAlign.center,
                      maxLines: 2,
                      overflow: TextOverflow.ellipsis,
                    ),
                    Align(
                      alignment: Alignment.centerRight,
                      child: isLoading
                          ? Visibility(
                              maintainState: true,
                              maintainAnimation: true,
                              maintainSize: true,
                              visible: isLoading,
                              child: Padding(
                                padding:
                                    const EdgeInsets.symmetric(horizontal: 16),
                                child: SizedBox(
                                  height: 24,
                                  width: 24,
                                  child: CupertinoActivityIndicator(
                                    color: whiteColor,
                                    radius: 12,
                                  ),
                                ),
                              ),
                            )
                          : const SizedBox(),
                    ),
                  ],
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
1
likes
0
points
21
downloads

Publisher

unverified uploader

Weekly Downloads

Flutter tool pack for allgood_nasiya active in Uzbekistan..

Homepage

License

unknown (license)

Dependencies

bloc, dio, flutter, flutter_bloc, mask_text_input_formatter, myid, plugin_platform_interface, sms_autofill, socket_io_client

More

Packages that depend on allgood_nasiya

Packages that implement allgood_nasiya