flutter_test_gen 0.1.2 copy "flutter_test_gen: ^0.1.2" to clipboard
flutter_test_gen: ^0.1.2 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_riverpod/flutter_riverpod.dart';
import 'package:flutter_test_gen_example/services/counter_service.dart';

void main() {
  runApp(const ProviderScope(child: 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 CounterService viewModel = CounterService();

  int counter = 0;

  @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(
                counter.toString(),
                style:
                    const TextStyle(fontSize: 40, fontWeight: FontWeight.bold),
              ),
              const SizedBox(height: 20),
              Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  ElevatedButton(
                    onPressed: () {
                      counter = viewModel.decrement(counter);
                      setState(() {});
                    },
                    child: const Text('-'),
                  ),
                  const SizedBox(width: 10),
                  ElevatedButton(
                    onPressed: () {
                      counter = viewModel.reset();
                      setState(() {});
                    },
                    child: const Text('Reset'),
                  ),
                  const SizedBox(width: 10),
                  ElevatedButton(
                    onPressed: () {
                      counter = viewModel.increment(counter);
                      setState(() {});
                    },
                    child: const Text('+'),
                  ),
                ],
              ),
            ],
          ),
        ),
      );
}
3
likes
0
points
34
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

License

unknown (license)

Dependencies

analyzer, ansi_styles, dart_style, path, yaml

More

Packages that depend on flutter_test_gen