You can use the following formula to sum values in Google Sheets if a corresponding checkbox is checked:
=SUM(ARRAYFORMULA(A2:A11*B2:B11))
This particular formula assumes that the values are in the range A2:A11 and the checkboxes are in the range B2:B11.
The following example shows how to use this formula in practice.
Example: Sum If Checkbox is Checked in Google Sheets
Suppose we have the following dataset in Google Sheets:

Note: You can add checkboxes to a range of cells by selecting a range, then clicking the Insert tab, then clicking Checkbox.
We can use the following formula to sum only the values in column A where the corresponding checkbox in column B is checked:
=SUM(ARRAYFORMULA(A2:A11*B2:B11))
The following screenshot shows how to use this formula in practice:

The sum of the values in column A where the corresponding checkbox in column B is checked is 172.
We can confirm this is correct by manually calculating the sum of the values in column A where the corresponding checkbox in column B is checked:
Sum of Checked Checkboxes: 20 + 29 + 26 + 31 + 51 + 15 = 172
This matches the value that we calculated using the formula.
Additional Resources
The following tutorials explain how to perform other common operations in Google Sheets:
How to Use SUMIF Contains in Google Sheets
How to Use SUMIF with OR in Google Sheets
How to Create a Cumulative Sum Chart in Google Sheets
Is there a way to invert it so it picks unchecked boxes instead?
it is possible to use this formula:
=SUM(ARRAYFORMULA(A2:A11*B2:B11))
but can I apply filters?
I would like that when applying the filters, it would give me a total only on the visible lines
what if the cells in column A and B are not contiguous, meaning if I have a cell with a value, then directly below a checkbox, then a value, then a checkbox down the column, like this: =SUM(ARRAYFORMULA(D3+D7+D9+D11+D13+D15*D4+D6+D8+D10+D12+D14+D16))
its adding all the values regardless of a checkbox or not.