ifp_detector 1.0.1 copy "ifp_detector: ^1.0.1" to clipboard
ifp_detector: ^1.0.1 copied to clipboard

PlatformAndroid
unlisted

Detect Interactive Flat Panels (IFPs) vs tablets on Android. Analyze screen size, brand, hardware features, and stylus support with confidence scoring for licensing and feature control.

example/lib/main.dart

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

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'IFP Detector Test',
      theme: ThemeData(primarySwatch: Colors.blue, useMaterial3: true),
      home: const IFPDetectorTest(),
    );
  }
}

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

  @override
  State<IFPDetectorTest> createState() => _IFPDetectorTestState();
}

class _IFPDetectorTestState extends State<IFPDetectorTest> {
  IfpDetectionResult? _detectionResult;
  bool _isLoading = false;
  String? _errorMessage;

  Future<void> _testPlugin() async {
    setState(() {
      _isLoading = true;
      _errorMessage = null;
      _detectionResult = null;
    });

    try {
      // Test both methods
      print('Testing simple isIfp() method...');
      final isIFP = await IfpDetector.isIfp();
      print('Simple result: $isIFP');

      print('Testing detailed detectIfp() method...');
      final result = await IfpDetector.detectIfp();
      print('Detailed result: $result');

      setState(() {
        _detectionResult = result;
      });

      // Show a snackbar with the simple result
      if (mounted) {
        ScaffoldMessenger.of(context).showSnackBar(
          SnackBar(
            content: Text(
              'Quick Result: ${isIFP ? "This is an IFP" : "This is a tablet"}',
            ),
            backgroundColor: isIFP ? Colors.orange : Colors.green,
          ),
        );
      }
    } on PlatformException catch (e) {
      print('PlatformException: ${e.message}');
      setState(() {
        _errorMessage = "Plugin Error: ${e.message}";
      });
    } catch (e) {
      print('Unexpected error: $e');
      setState(() {
        _errorMessage = "Unexpected error: $e";
      });
    } finally {
      setState(() {
        _isLoading = false;
      });
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('IFP Detector Plugin Test'),
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
      ),
      body: Padding(
        padding: const EdgeInsets.all(16.0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: [
            Card(
              child: Padding(
                padding: const EdgeInsets.all(20.0),
                child: Column(
                  children: [
                    const Icon(Icons.science, size: 48, color: Colors.blue),
                    const SizedBox(height: 12),
                    const Text(
                      'Plugin Functionality Test',
                      style: TextStyle(
                        fontSize: 24,
                        fontWeight: FontWeight.bold,
                      ),
                    ),
                    const SizedBox(height: 8),
                    const Text(
                      'This will test if the IFP Detector plugin is working correctly on your device.',
                      textAlign: TextAlign.center,
                      style: TextStyle(color: Colors.grey),
                    ),
                  ],
                ),
              ),
            ),
            const SizedBox(height: 20),
            ElevatedButton.icon(
              onPressed: _isLoading ? null : _testPlugin,
              icon: const Icon(Icons.play_arrow),
              label: Text(_isLoading ? 'Testing Plugin...' : 'Test Plugin'),
              style: ElevatedButton.styleFrom(
                padding: const EdgeInsets.symmetric(vertical: 16),
                textStyle: const TextStyle(fontSize: 18),
              ),
            ),
            const SizedBox(height: 20),
            if (_isLoading)
              const Center(
                child: Column(
                  children: [
                    CircularProgressIndicator(),
                    SizedBox(height: 16),
                    Text('Running detection algorithms...'),
                  ],
                ),
              )
            else if (_errorMessage != null)
              Card(
                color: Colors.red.shade50,
                child: Padding(
                  padding: const EdgeInsets.all(16.0),
                  child: Column(
                    children: [
                      const Icon(Icons.error, color: Colors.red, size: 48),
                      const SizedBox(height: 8),
                      const Text(
                        'Plugin Test Failed',
                        style: TextStyle(
                          fontSize: 18,
                          fontWeight: FontWeight.bold,
                          color: Colors.red,
                        ),
                      ),
                      const SizedBox(height: 8),
                      Text(
                        _errorMessage!,
                        style: const TextStyle(color: Colors.red),
                        textAlign: TextAlign.center,
                      ),
                    ],
                  ),
                ),
              )
            else if (_detectionResult != null)
              Expanded(child: _buildSuccessCard())
            else
              const Expanded(
                child: Center(
                  child: Text(
                    'Tap the button above to test the plugin',
                    style: TextStyle(fontSize: 16, color: Colors.grey),
                  ),
                ),
              ),
          ],
        ),
      ),
    );
  }

  Widget _buildSuccessCard() {
    final result = _detectionResult!;
    return Card(
      color: Colors.green.shade50,
      child: Padding(
        padding: const EdgeInsets.all(16.0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Row(
              children: [
                const Icon(Icons.check_circle, color: Colors.green, size: 32),
                const SizedBox(width: 12),
                const Expanded(
                  child: Text(
                    'Plugin Test Successful! βœ…',
                    style: TextStyle(
                      fontSize: 20,
                      fontWeight: FontWeight.bold,
                      color: Colors.green,
                    ),
                  ),
                ),
              ],
            ),
            const SizedBox(height: 16),
            const Text(
              'Detection Results:',
              style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
            ),
            const SizedBox(height: 12),
            _buildResultRow(
              'Device Type',
              result.isIFP ? 'Interactive Flat Panel (IFP)' : 'Regular Tablet',
            ),
            _buildResultRow(
              'Confidence Level',
              '${result.confidenceLevel} (${(result.confidenceScore * 100).toStringAsFixed(1)}%)',
            ),
            _buildResultRow(
              'Screen Size',
              '${result.screenInches.toStringAsFixed(2)}" diagonal',
            ),
            _buildResultRow('Screen Bucket', result.screenBucket),
            _buildResultRow(
              'Known IFP Brand',
              result.matchedKnownIFPBrand ? 'Yes' : 'No',
            ),
            _buildResultRow(
              'HDMI CEC Support',
              result.hasHdmiCec ? 'Yes' : 'No',
            ),
            _buildResultRow('Leanback UI', result.hasLeanback ? 'Yes' : 'No'),
            _buildResultRow('Stylus Support', result.hasStylus ? 'Yes' : 'No'),
            _buildResultRow(
              'Screen Size Reliable',
              result.screenSizeReliable ? 'Yes' : 'No',
            ),
            const SizedBox(height: 16),
            Container(
              width: double.infinity,
              padding: const EdgeInsets.all(12),
              decoration: BoxDecoration(
                color: Colors.blue.shade50,
                borderRadius: BorderRadius.circular(8),
                border: Border.all(color: Colors.blue.shade200),
              ),
              child: const Text(
                'πŸŽ‰ The plugin is working perfectly! All detection methods executed successfully.',
                style: TextStyle(
                  fontSize: 16,
                  fontWeight: FontWeight.w500,
                  color: Colors.blue,
                ),
                textAlign: TextAlign.center,
              ),
            ),
          ],
        ),
      ),
    );
  }

  Widget _buildResultRow(String label, String value) {
    return Padding(
      padding: const EdgeInsets.symmetric(vertical: 4.0),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          SizedBox(
            width: 140,
            child: Text(
              '$label:',
              style: const TextStyle(fontWeight: FontWeight.w500),
            ),
          ),
          Expanded(
            child: Text(value, style: const TextStyle(color: Colors.grey)),
          ),
        ],
      ),
    );
  }
}
0
likes
150
points
124
downloads

Publisher

unverified uploader

Weekly Downloads

Detect Interactive Flat Panels (IFPs) vs tablets on Android. Analyze screen size, brand, hardware features, and stylus support with confidence scoring for licensing and feature control.

Repository (GitHub)
View/report issues

Topics

#ifp #device-detection #tablet #android #education

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on ifp_detector

Packages that implement ifp_detector