flutter_sdui_test 1.1.0 copy "flutter_sdui_test: ^1.1.0" to clipboard
flutter_sdui_test: ^1.1.0 copied to clipboard

Testing utilities for Flutter SDUI framework. Provides sduiGoldenTest() for side-by-side native vs SDUI golden comparisons.

example/flutter_sdui_test_example.dart

import 'package:flutter/material.dart';
import 'package:flutter_sdui_test/flutter_sdui_test.dart';

// Add to dev_dependencies:
//
//   dev_dependencies:
//     flutter_sdui_test: ^<version>
//
// Then run:
//   flutter test                  # compare against goldens
//   flutter test --update-goldens # regenerate goldens

// ── Example native widget ─────────────────────────────────────────────────────

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

  @override
  Widget build(BuildContext context) {
    return const Padding(
      padding: EdgeInsets.all(24),
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: [
          Text('Welcome back', style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold)),
          SizedBox(height: 8),
          Text('Sign in to continue', style: TextStyle(color: Colors.grey)),
        ],
      ),
    );
  }
}

// ── Tests ─────────────────────────────────────────────────────────────────────

void main() {
  // Load schema from a JSON file on disk.
  // Generates two goldens per device:
  //   test/goldens/login_screen_phone_native.png
  //   test/goldens/login_screen_phone_sdui.png
  sduiGoldenTest(
    'login screen',
    nativeWidget: const LoginScreen(),
    schemaPath: 'test/fixtures/login.json',
    devices: [SduiDevices.phone, SduiDevices.tablet],
    threshold: 0.01, // up to 1% pixel diff allowed
  );

  // Or provide the schema inline — useful for quick iteration.
  sduiGoldenTest(
    'inline screen',
    nativeWidget: const LoginScreen(),
    schema: {
      'screen': 'login',
      'body': {
        'type': 'padding',
        'props': {'all': 24},
        'children': [
          {
            'type': 'column',
            'props': {'main_alignment': 'center'},
            'children': [
              {
                'type': 'text',
                'props': {'content': 'Welcome back', 'style': 'heading'},
              },
              {'type': 'spacer', 'props': {'height': 8}},
              {
                'type': 'text',
                'props': {
                  'content': 'Sign in to continue',
                  'color': '#9E9E9E',
                },
              },
            ],
          },
        ],
      },
    },
  );
}
3
likes
160
points
30
downloads

Documentation

API reference

Publisher

verified publisherchinmaysinghmodak.com

Weekly Downloads

Testing utilities for Flutter SDUI framework. Provides sduiGoldenTest() for side-by-side native vs SDUI golden comparisons.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, flutter_sdui_kit, flutter_test

More

Packages that depend on flutter_sdui_test