pocketpy 2.0.4 copy "pocketpy: ^2.0.4" to clipboard
pocketpy: ^2.0.4 copied to clipboard

A lightweight Python interpreter for game engines. It supports Android/iOS/Windows/Linux/MacOS.

example/lib/main.dart

import 'dart:ffi';
import 'package:ffi/ffi.dart';
import 'package:flutter/material.dart';

import 'package:pocketpy/pocketpy.dart';
import 'package:pocketpy/pocketpy_bindings_generated.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  Widget build(BuildContext context) {
    bool ok = pocket.py_exec(
        'import sys\nprint(sys.version)'.toNativeUtf8().cast(),
        'main.py'.toNativeUtf8().cast(),
        py_CompileMode.EXEC_MODE,
        Pointer.fromAddress(0));

    if (!ok) {
      pocket.py_printexc();
    }

    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Native Packages'),
        ),
        body: SingleChildScrollView(
          child: Container(
            padding: const EdgeInsets.all(10),
            child: const Text(""),
          ),
        ),
      ),
    );
  }
}
12
likes
140
points
267
downloads

Publisher

verified publisherpocketpy.dev

Weekly Downloads

A lightweight Python interpreter for game engines. It supports Android/iOS/Windows/Linux/MacOS.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

ffi, flutter, plugin_platform_interface

More

Packages that depend on pocketpy