How to create a button on top toolbar in mobile for **Flutter**

Hi PDFTron,
I wanna create a button on top toolbar in mobile. How to make it in ((Flutter))*** ?

i will create button for export annotations ((Flutter))
Thank you!

Hi there,

Unfortunately in order to change the menu options in the toolbar you will have to do implement this using native code.
Please see this guide on how to customise the menu options in the Android toolbar.

Please let us know if this works for you.

Best Regards,
Eamon

Hi Eamon,
I’ve never used kotlin, I thought I had to do it via methodchanel in flutter, do you have an example code (kotlin) create button on githup?
thank you

Hi,

We have a Custom UI Sample in Java which you can reference here.

You will need to create a custom menu xml file inside your android projects menu folder.

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item
        android:id="@+id/action_show_toast"
        android:title="YOUR MENU OPTION 1"
        app:showAsAction="never" />
    <item
        android:id="@+id/action_show_toast_2"
        android:title="YOUR MENU OPTION 2"
        app:showAsAction="always" />
</menu>

Then add that custom menu to the ViewerBuilder in your project with the usingCustomToolbar API

mPdfViewCtrlTabHostFragment = ViewerBuilder2.withUri("YOUR FILE URI")
                .usingCustomToolbar(new int[]{R.menu.my_custom_options_toolbar})
                .build(this);

After you have added your custom menu you can add this to handle your menu item clicks.

Best,
Eamon