flutter_test_gen 0.1.0 copy "flutter_test_gen: ^0.1.0" to clipboard
flutter_test_gen: ^0.1.0 copied to clipboard

A CLI tool to automatically generate Flutter and Dart unit tests. Generates structured test templates for classes and functions to speed up Flutter testing.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_test_gen_example/counter_view_model.dart';

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

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

  @override
  Widget build(BuildContext context) => const MaterialApp(
        home: CounterPage(),
      );
}

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

  @override
  State<CounterPage> createState() => _CounterPageState();
}

class _CounterPageState extends State<CounterPage> {
  final CounterViewModel viewModel = CounterViewModel();

  @override
  void initState() {
    super.initState();
    viewModel.addListener(_update);
  }

  void _update() => setState(() {});

  @override
  void dispose() {
    viewModel.removeListener(_update);
    super.dispose();
  }

  @override
  Widget build(BuildContext context) => Scaffold(
        appBar: AppBar(
          title: const Text('Counter App'),
        ),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              const Text(
                'Counter Value',
                style: TextStyle(fontSize: 20),
              ),
              Text(
                '${viewModel.counter}',
                style: const TextStyle(
                  fontSize: 40,
                  fontWeight: FontWeight.bold,
                ),
              ),
              const SizedBox(height: 20),
              Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  ElevatedButton(
                    onPressed: viewModel.decrement,
                    child: const Text('-'),
                  ),
                  const SizedBox(width: 10),
                  ElevatedButton(
                    onPressed: viewModel.reset,
                    child: const Text('Reset'),
                  ),
                  const SizedBox(width: 10),
                  ElevatedButton(
                    onPressed: viewModel.increment,
                    child: const Text('+'),
                  ),
                ],
              ),
            ],
          ),
        ),
      );
}
3
likes
140
points
184
downloads

Publisher

unverified uploader

Weekly Downloads

A CLI tool to automatically generate Flutter and Dart unit tests. Generates structured test templates for classes and functions to speed up Flutter testing.

Homepage
Repository (GitHub)
View/report issues

Topics

#testing #unit-tests #test-generation #cli #code-generation

Documentation

API reference

License

MIT (license)

Dependencies

analyzer, ansi_styles, dart_style, yaml

More

Packages that depend on flutter_test_gen