canvas_test 0.2.0 copy "canvas_test: ^0.2.0" to clipboard
canvas_test: ^0.2.0 copied to clipboard

A package with classes to help testing applications using the canvas

example/lib/main.dart

import 'package:flutter/material.dart';

const Color darkBlue = Color.fromARGB(255, 18, 32, 47);

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: darkBlue),
      debugShowCheckedModeBanner: false,
      home: Scaffold(
        // Outer white container with padding
        body: Container(
          color: Colors.white,
          padding: const EdgeInsets.symmetric(horizontal: 40, vertical: 80),
          // Inner yellow container
          child: Container(
            // pass double.infinity to prevent shrinking of the painter area to 0.
            width: double.infinity,
            height: double.infinity,
            color: Colors.black,
            child: CustomPaint(painter: RectanglePainter()),
          ),
        ),
      ),
    );
  }
}

class RectanglePainter extends CustomPainter {
  @override
  void paint(Canvas canvas, Size size) {
    final paint = Paint()
      ..style = PaintingStyle.stroke
      ..strokeWidth = 4.0
      ..color = Colors.indigo;

    canvas.drawRect(
      const Rect.fromLTWH(100, 100, 100, 100),
      paint,
    );
  }

  @override
  bool shouldRepaint(RectanglePainter oldDelegate) => false;
}
4
likes
130
pub points
49%
popularity

Publisher

verified publisherblue-fire.xyz

A package with classes to help testing applications using the canvas

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, flutter_test, test, vector_math

More

Packages that depend on canvas_test