cocoa 0.0.1
cocoa: ^0.0.1 copied to clipboard
A Flutter plugin to interact with macOS Cocoa APIs using FFI.
example/lib/main.dart
import 'dart:async';
import 'dart:ffi';
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:native_binding/native_binding_bindings_generated.dart';
import 'package:objective_c/objective_c.dart' as objc;
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
late int sumResult;
late Future<int> sumAsyncResult;
late String systemVersion;
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
const textStyle = TextStyle(fontSize: 25);
const spacerSmall = SizedBox(height: 10);
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Native Packages')),
body: SingleChildScrollView(
child: Container(
padding: const EdgeInsets.all(10),
child: Column(
children: [
const Text(
'This calls a native function through FFI that is shipped as source in the package. '
'The native code is built as part of the Flutter Runner build.',
style: textStyle,
textAlign: TextAlign.center,
),
TextButton(
onPressed: () {
NSApplication.getSharedApplication().keyWindow$1
?.toggleFullScreen(null);
},
child: const Text('Toggle Full Screen'),
),
],
),
),
),
),
);
}
}