quixxi 0.0.5 copy "quixxi: ^0.0.5" to clipboard
quixxi: ^0.0.5 copied to clipboard

Flutter plugin for adding SSL Pinning to application, Prevent copy and paste inside the application.

example/lib/main.dart

import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import 'package:dio/dio.dart';
import 'package:quixxi/services.dart';

import 'package:get/get_rx/src/rx_types/rx_types.dart';
import 'package:get/get_state_manager/src/rx_flutter/rx_obx_widget.dart';

import 'helper/AppConstants/app_constants.dart';
import 'helper/CustomColors/custom_colors.dart';
import 'helper/CustomWidgets/custom_widgets.dart';

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

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

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

class _PiningSslData {
  String serverURL = '';
  Map<String, String> headerHttp = {};
  String allowedSHAFingerprint = '';
  int timeout = 0;
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = '0.0.1';
  final _quixxiShieldPlugin = QuixxiShieldPlugin();
  final GlobalKey<FormState> _formKey = GlobalKey<FormState>();
  final _PiningSslData _data = _PiningSslData();
  final _messengerKey = GlobalKey<ScaffoldMessengerState>();

  @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 _quixxiShieldPlugin.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;
    });
  }

// This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: AppConstants.appName,
      theme: ThemeData(
        useMaterial3: false,
        colorScheme: ColorScheme.fromSeed(
          seedColor: CustomColors.themeColor,
          brightness: Brightness.light,
        ),
      ),
      debugShowCheckedModeBanner: false,
      home: const DashboardScreen(),
    );
  }
}

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

  @override
  State<DashboardScreen> createState() => _DashboardScreenState();
}

class _DashboardScreenState extends State<DashboardScreen> {

  Dio dioClient = getDioClient('https://gorest.co.in');
  SecureHttpClient secureHttpClient = getSecureHttpClient();

  RxString apiResponse = ''.obs;
  RxBool isLoading = false.obs;
  var urlTextEditingController = TextEditingController(text: 'https://gorest.co.in/public/v2/todos');

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: Container(
          color: CustomColors.primaryBackground,
          child: Column(children: [
            Container(
              height: 50,
              color: CustomColors.themeColor,
              child: const Center(
                child: customTxt(
                  text: AppConstants.appName,
                  color: CustomColors.lightTxtColor,
                  fontWeight: FontWeight.w500,
                ),
              ),
            ),
            Expanded(
              child: SingleChildScrollView(
                child: Padding(
                  padding: const EdgeInsets.symmetric(horizontal: 20),
                  child: Column(
                    children: [
                      const SizedBox(height: 20),
                      Column(
                        crossAxisAlignment: CrossAxisAlignment.start,
                        children: [
                          const Center(
                            child: customTxt(
                              text: 'Disable Copy and Paste',
                              size: 20,
                              align: TextAlign.center,
                              fontWeight: FontWeight.w500,
                            ),
                          ),
                          const SizedBox(height: 10),
                          // const customTxt(text: 'Quixxi Textfield'),
                          Container(
                            padding: const EdgeInsets.symmetric(vertical: 5),
                            child: QuixxiTextField(
                              decoration: const InputDecoration(
                                border: OutlineInputBorder(),
                                hintText: 'Quixxi Textfield',
                              ),
                              keyboardType: TextInputType.url,
                              textInputAction: TextInputAction.next,
                              controller: TextEditingController(text: ""),
                            ),
                          ),
                          const SizedBox(height: 10),
                          // const customTxt(text: 'Quixxi TextFormfield'),
                          Container(
                            padding: const EdgeInsets.symmetric(vertical: 5),
                            child: QuixxiTextFormField(
                              decoration: const InputDecoration(
                                border: OutlineInputBorder(),
                                hintText: 'Quixxi TextFormfield',
                              ),
                              keyboardType: TextInputType.url,
                              textInputAction: TextInputAction.next,
                              controller: TextEditingController(text: ""),
                              onSaved: (value) {},
                              validator: (value) {},
                            ),
                          ),
                          const SizedBox(height: 5),
                          const customTxt(
                            text:
                            'Note: Quixxi components which does not allows copy and paste functionality',
                            size: 14,
                            color: CustomColors.lightGreyColor,
                            fontWeight: FontWeight.w500,
                          ),
                        ],
                      ),
                      const SizedBox(height: 20),
                      const Center(
                        child: customTxt(
                          text: 'SSL Pinning',
                          size: 20,
                          align: TextAlign.center,
                          fontWeight: FontWeight.w500,
                        ),
                      ),
                      const SizedBox(height: 10),
                      TextFormField(
                        decoration: const InputDecoration(
                          border: OutlineInputBorder(),
                          hintText: 'Enter Url',
                        ),
                        keyboardType: TextInputType.url,
                        textInputAction: TextInputAction.done,
                        controller: urlTextEditingController,
                      ),
                      const SizedBox(height: 15),
                      InkWell(
                        onTap: () {
                          setState(() {
                            isLoading.value = true;
                            apiCall2();
                          });
                        },
                        child: Container(
                          decoration: BoxDecoration(
                            borderRadius: BorderRadius.circular(8),
                            color: CustomColors.themeColor,
                          ),
                          padding: const EdgeInsets.symmetric(
                              horizontal: 15, vertical: 10),
                          child: const customTxt(
                              text: 'Connect',
                              color: CustomColors.lightTxtColor),
                        ),
                      ),
                      // Add the commented row here to enable 3 sections
                      const SizedBox(height: 20),
                      Stack(
                        children: [
                          Align(
                            alignment: Alignment.topLeft,
                            child: Obx(
                                  () => customTxt(

                                text: isLoading.value ? "Connecting with server .." : apiResponse.value,
                              ),
                            ),
                          ),
                        ],
                      ),
                      const SizedBox(height: 30)
                    ],
                  ),
                ),
              ),
            ),
          ]),
        ),
      ),
    );
  }

  void apiCall() async {
    var header = {'Content-type': 'application/json; charset=utf-8'};
    try {
      
      final response = await dioClient.get(urlTextEditingController.text,
          options: Options(headers: header));
      isLoading.value = false;
      if (response.statusCode == 200) {
        apiResponse.value = response.data.toString();
      } else {
        print('${response.statusCode} : ${response.data.toString()}');
        apiResponse.value = response.data.toString();
      }
    } catch (error) {
      isLoading.value = false;
      apiResponse.value = error.toString();
    }
  }

  void apiCall2()async{
    
    var header = {'Content-type': 'application/json; charset=utf-8'};
    try {
      Uri uri = Uri.parse(urlTextEditingController.text);
      final response = await secureHttpClient.get(uri);
      isLoading.value = false;
      if (response.statusCode == 200) {
        apiResponse.value = response.body.toString();
      } else {
        print('${response.statusCode} : ${response.toString()}');
        apiResponse.value = response.body.toString();
      }
    } catch (error) {
      isLoading.value = false;
      apiResponse.value = error.toString();
    }
  }
  
}
5
likes
120
points
43
downloads

Publisher

verified publisherquixxi.com

Weekly Downloads

Flutter plugin for adding SSL Pinning to application, Prevent copy and paste inside the application.

Homepage

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

convert, dio, encrypt, flutter, http, plugin_platform_interface, pointycastle, string_validator

More

Packages that depend on quixxi