flutter_design_guard 0.1.2 copy "flutter_design_guard: ^0.1.2" to clipboard
flutter_design_guard: ^0.1.2 copied to clipboard

Dart Analyzer plugin that enforces Flutter design-system widgets and colors.

example/lib/main.dart

import 'package:flutter/material.dart';

import 'widgets/app_field.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(home: ExampleScreen());
  }
}

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

  @override
  Widget build(BuildContext context) {
    final colorScheme = Theme.of(context).colorScheme;

    return Scaffold(
      appBar: AppBar(title: const Text('Flutter Design Guard')),
      body: Padding(
        padding: const EdgeInsets.all(16),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.stretch,
          children: [
            // Reported by avoid_native_text_field when used directly:
            // TextField();
            // TextFormField();
            const AppField(label: 'Name'),
            const SizedBox(height: 16),
            const AppField.form(label: 'Email'),
            const SizedBox(height: 24),
            Container(
              padding: const EdgeInsets.all(16),
              decoration: BoxDecoration(
                // Colors.blue and Color(0xFF...) would be reported by
                // avoid_hardcoded_color. Theme colors are approved.
                color: colorScheme.primaryContainer,
                borderRadius: BorderRadius.circular(12),
              ),
              child: Text(
                'Use theme colors instead of hardcoded colors.',
                style: TextStyle(color: colorScheme.onPrimaryContainer),
              ),
            ),
          ],
        ),
      ),
    );
  }
}
4
likes
160
points
336
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Dart Analyzer plugin that enforces Flutter design-system widgets and colors.

Repository (GitHub)
View/report issues

Topics

#analyzer #flutter #lints #static-analysis #code-quality

License

BSD-3-Clause (license)

Dependencies

analysis_server_plugin, analyzer, analyzer_plugin, yaml

More

Packages that depend on flutter_design_guard