Getting error : At least one signature didn't pass verification

Hi guys,

I’am trying to send a transaction in TestNet using Algorand dart

 Address recipient = Address.fromAlgorandAddress(receiverTestNetAddress);
 Address sender = Address.fromAlgorandAddress(

TransactionParams transactionParams = TransactionParams(
        consensusVersion: params['consensus-version'],
        fee: fee,
        genesisId: params['genesis-id'],
        genesisHash: genesisHashBytes,
        lastRound: BigInt.from(params['last-round']),
        minFee: BigInt.from(params['min-fee']));
    final transaction = await (PaymentTransactionBuilder()
          ..sender =  sender
          ..noteText = 'Hello world'
          ..amount = amount
          ..receiver = null
          ..suggestedParams = transactionParams)

 final encodedTransaction = transaction.getEncodedTransaction();

      final signature = await Ed25519().sign(
        keyPair: keyPair,

      // Create the signed transaction with signature
      final signedTransaction = ref.SignedTransaction(
        signature: Uint8List.fromList(signature.bytes),
        transaction: transaction,

      signedTransaction.authAddress = address ;

      final encodedTxBytes =

      final responseSendTxn = await
        headers: {'Content-Type': 'application/x-binary'},
        body: encodedTxBytes,

      if (responseSendTxn.statusCode != 200) {
         throw Exception('Failed to send transaction');

when i add the sender i get this error message :
** At least one signature didn’t pass verification**

when i remove it ( just for testing) i get this :
invalid : transaction cannot close account to its sender