smart_dev_pinning_plugin 1.0.0 copy "smart_dev_pinning_plugin: ^1.0.0" to clipboard
smart_dev_pinning_plugin: ^1.0.0 copied to clipboard

This plugin creates a secure native TLS connection to execute HTTP requests with certificate pinning.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:smart_dev_pinning_plugin/smart_dev_pinning_plugin.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 response = "Launch Request";

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

  @override
  Widget build(BuildContext context) {
    const textStyle = TextStyle(fontSize: 15, color: Colors.black);
    const spacerSmall = SizedBox(height: 10);
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('Native Packages')),
        body: SingleChildScrollView(
          child: Container(
            padding: const EdgeInsets.all(10),
            child: Column(
              children: [
                const Text(
                  'This calls a native function through FFI that is shipped as source in the package. '
                  'The native code is built as part of the Flutter Runner build.',
                  style: textStyle,
                  textAlign: TextAlign.center,
                ),
                spacerSmall,
                ElevatedButton(
                  onPressed: () async {
                    try {
                      final client = SecureClient();
                      final requestResponse = await client.httpRequest(
                        certificateHash:
                            "Mh7ufr6Yepdwv4IGnMFCJcVG9P0YeIqzaMr+euJo0/U=",
                        method: 'GET',
                        url: 'https://jsonplaceholder.typicode.com/posts/1',
                        headers: {
                          'Content-type': 'application/json; charset=UTF-8',
                        },
                      );
                      setState(() {
                        response = requestResponse;
                      });
                    } catch (e) {
                      setState(() {
                        response = e.toString();
                      });
                    }
                  },
                  child: const Text('Make request'),
                ),
                spacerSmall,
                const Text('Response:', style: textStyle),
                const SizedBox(height: 10),
                Text(response, style: textStyle),
                const SizedBox(height: 10),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
1
likes
130
points
194
downloads

Publisher

verified publishersmart-dev.com.co

Weekly Downloads

This plugin creates a secure native TLS connection to execute HTTP requests with certificate pinning.

Documentation

API reference

License

unknown (license)

Dependencies

crypto, ffi, flutter, plugin_platform_interface

More

Packages that depend on smart_dev_pinning_plugin

Packages that implement smart_dev_pinning_plugin