rython 0.1.3
rython: ^0.1.3 copied to clipboard
Executing Python scripts in Flutter with Rust
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:rython/rython.dart';
Future<void> main() async {
await Rython.init();
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Rython')),
body: Center(
child: Column(children: [
const Text('Run Python :'),
Text('Result : ${eval(script: "print('Hello, Rython')")}'),
Text('Result Eval : ${eval(script: "1 + 1")}'),
Text(
'Result Exec : ${exec(script: "def my_function():\n return 1 + 2\nmy_function()")}')
]))));
}
}