Errors when adding page urls via panel

I have added a link to an internal page using the panel, ideally, users can adjust which page they would like the button to take them. This is the error: Attempt to read property “url” on null

PHP     
<a href="<?= $page->Button1URL()->toFile()->url ?>" >Button</a>
     
YML
 Button1URL:
        label: Button 1 URL
        type: pages
        width: 1/3

TXT
Button1url:
- about

You’re using pages field and toFile() method, try toPage() method.

<?php if($buttonPage = $page->Button1URL()->toPage()): ?>
    <a href="<?= $buttonPage->url() ?>" >Button</a>
<?php endif; ?>

@ahmetbora Thank you this worked like a charm.