How can ı access method from one statefulWidget in another Widget for canvas

ı create canvas for users can draw.And ı am trying to do use in that canvas another screen. I add button for clear. But ı cant access the clear method,

when I looked at the previous opened questions on stackoverflow, I saw that it is used in InheritedWidget. at first I used an object from my canvas class, but I couldn’t see the method.

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

import '../../../core/util/app_sizes.dart';

class ThetaCanvas extends StatefulWidget {
  const ThetaCanvas({Key? key}) : super(key: key);

  @override
  State<ThetaCanvas> createState() => _ThetaCanvasState();
}

class _ThetaCanvasState extends State<ThetaCanvas> {
  List<DrawingArea?> points = [];
  late double opacity;

  @override
  void initState() {
    super.initState();
    opacity = 1.0;
  }

   clearThetaCanvas() {
    setState(() {
      points.clear();
    });
  }

  @override
  Widget build(BuildContext context) {
    return ClipRect(
      child: Container(
        height: AppSizes.screenHeight / 4,
        width: AppSizes.screenWidth,
        decoration: BoxDecoration(color: Colors.white70, borderRadius: BorderRadius.circular(25)),
        child: GestureDetector(
          onPanDown: (details) {
            setState(() {
              points.add(DrawingArea(
                point: details.localPosition,
                areaPaint: Paint()
                  ..color = Colors.black.withOpacity(opacity)
                  ..strokeCap = StrokeCap.round
                  ..isAntiAlias = true
                  ..strokeWidth = 2.0,
              ));
            });
          },
          onPanUpdate: (details) {
            setState(() {
              points.add(DrawingArea(
                point: details.localPosition,
                areaPaint: Paint()
                  ..color = Colors.black.withOpacity(opacity)
                  ..strokeCap = StrokeCap.round
                  ..isAntiAlias = true
                  ..strokeWidth = 2.0,
              ));
            });
          },
          onPanEnd: (details) {
            points.add(null);
          },
          child: CustomPaint(
            size: Size.infinite,
            painter: DrawingPainter(pointsList: points),
          ),
        ),
      ),
    );
  }
}

class DrawingPainter extends CustomPainter {
  List<DrawingArea?> pointsList;

  DrawingPainter({required this.pointsList});

  @override
  void paint(Canvas canvas, Size size) {
    for (int i = 0; i < pointsList.length - 1; i++) {
      if (pointsList[i] != null && pointsList[i + 1] != null) {
        canvas.drawLine(
          pointsList[i]!.point,
          pointsList[i + 1]!.point,
          pointsList[i]!.areaPaint,
        );
      } else if (pointsList[i] != null && pointsList[i + 1] == null) {
        canvas.drawPoints(PointMode.points, [pointsList[i]!.point], pointsList[i]!.areaPaint);
      }
    }
  }

  @override
  bool shouldRepaint(covariant CustomPainter oldDelegate) {
    return true;
  }
}

class DrawingArea {
  Offset point;
  Paint areaPaint;

  DrawingArea({required this.point, required this.areaPaint});
}

and here is my button


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

  @override
  Widget build(BuildContext context) {
    final ThetaCanvas thetaCanvas = ThetaCanvas();

    return TextButton(
      onPressed: () {
        
      },
      style: ButtonStyle(
        splashFactory: InkRipple.splashFactory,
        overlayColor: MaterialStateProperty.resolveWith<Color>(
          (Set<MaterialState> states) {
            if (states.contains(MaterialState.pressed)) {
              return Colors.white
                  .withOpacity(0.4); 
            }
            return Colors.transparent; 
          },
        ),
      ),
      child: Container(
        padding: const EdgeInsets.all(8),
        decoration: BoxDecoration(
          border: Border.all(color: Colors.white), 
          borderRadius: BorderRadius.circular(25), 
        ),
        child: Row(
          mainAxisSize: MainAxisSize.min, 
          children: [
            Text(
              'NEXT',
              style: Theme.of(context).textTheme.displaySmall?.copyWith(color: Colors.white),
            ),
            const Icon(
              Icons.chevron_right_outlined,
              color: Colors.white,
              size: 40,
            ),
          ],
        ),
      ),
    );
  }
}

when ı write the thetaCanvas.clearThetaCanvas its says

The method ‘clearThetaCanvas’ isn’t defined for the type ‘ThetaCanvas’.
Try correcting the name to the name of an existing method, or defining a method named ‘clearThetaCanvas’

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật