Sample code for 30+ languages & platforms
Dart Requires Chilkat v11.0.0+

Duplicate openssl pkey -in private.pem -pubout -out pubkey.pem

See more OpenSSL Examples

How to output the public part of a private key: Demonstrates how to duplicate this OpenSSL command:
openssl pkey -in private.pem -pubout -out pubkey.pem

Chilkat Dart Downloads

Dart
import 'package:chilkat/chilkat.dart';

void main() {
  final pkey = CkPrivateKey();

  // Load the private key from an PEM file:
  try {
    pkey.loadPemFile('private.pem');
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  final pubKey = CkPublicKey();
  pkey.toPublicKey(pubKey);

  try {
    pubKey.savePemFile(false, 'pubKey.pem');
  } on ChilkatException catch (e) {
    print(e.lastErrorText);

    return;
  }

  print('Success.');
}