main.dart 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import 'dart:ffi';
  2. import 'package:ffi/ffi.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:pocketpy/pocketpy.dart';
  5. import 'package:pocketpy/pocketpy_bindings_generated.dart';
  6. void main() {
  7. runApp(const MyApp());
  8. }
  9. class MyApp extends StatefulWidget {
  10. const MyApp({super.key});
  11. @override
  12. State<MyApp> createState() => _MyAppState();
  13. }
  14. class _MyAppState extends State<MyApp> {
  15. @override
  16. Widget build(BuildContext context) {
  17. bool ok = pocket.py_exec(
  18. 'import sys\nprint(sys.version)'.toNativeUtf8().cast(),
  19. 'main.py'.toNativeUtf8().cast(),
  20. py_CompileMode.EXEC_MODE,
  21. Pointer.fromAddress(0));
  22. if (!ok) {
  23. pocket.py_printexc();
  24. }
  25. return MaterialApp(
  26. home: Scaffold(
  27. appBar: AppBar(
  28. title: const Text('Native Packages'),
  29. ),
  30. body: SingleChildScrollView(
  31. child: Container(
  32. padding: const EdgeInsets.all(10),
  33. child: const Text(""),
  34. ),
  35. ),
  36. ),
  37. );
  38. }
  39. }