You can use my package for flutter flutter_phantom
Future<web3.Transaction> createTransactionTransfer() async {
final transaction = web3.Transaction(
feePayer: phantom.phantomWalletPublicKey,
recentBlockhash: (await connection.getLatestBlockhash()).blockhash);
transaction.add(
SystemProgram.transfer(
fromPublicKey: phantom.phantomWalletPublicKey,
toPublicKey: phantom.phantomWalletPublicKey,
lamports: web3.solToLamports(1),
),
);
return transaction;
}
void signAndSendTransaction() async {
try {
web3.Transaction transaction = await createTransactionTransfer();
web3.Buffer transactionSerialize = transaction
.serialize(const web3.SerializeConfig(requireAllSignatures: false));
final url = phantom.generateSignAndSendTransactionUri(
transaction: transactionSerialize,
redirect: "onSignAndSendTransaction");
launchUrl(
url,
mode: LaunchMode.externalNonBrowserApplication,
);
} catch (e) {
print(e)
}
}
full example of how to use this package (Android,Ios) flutter_phantom-demo.