live_beauty_filter 1.0.1
live_beauty_filter: ^1.0.1 copied to clipboard
A Flutter plugin for iOS that applies a real-time milky/soft beauty filter to the live camera feed, entirely on the GPU. Built on AVFoundation + CoreImage + Metal — zero CPU pixel processing.
import 'package:flutter/material.dart';
import 'package:live_beauty_filter/live_beauty_filter.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
title: 'live_beauty_filter example',
debugShowCheckedModeBanner: false,
home: ExampleScreen(),
);
}
}
class ExampleScreen extends StatefulWidget {
const ExampleScreen({super.key});
@override
State<ExampleScreen> createState() => _ExampleScreenState();
}
class _ExampleScreenState extends State<ExampleScreen> {
final _controller = MilkyFilterController();
double _intensity = 0.7;
String _status = 'Initializing...';
@override
void initState() {
super.initState();
_initCamera();
}
Future<void> _initCamera() async {
try {
await _controller.initialize();
setState(() => _status = 'Ready');
} catch (e) {
setState(() => _status = 'Error: $e');
}
}
@override
void dispose() {
_controller.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.black,
body: SafeArea(
child: Stack(
fit: StackFit.expand,
children: [
// Camera preview
if (_controller.isInitialized)
Texture(textureId: _controller.textureId!)
else
Center(
child: Text(
_status,
style: const TextStyle(color: Colors.white, fontSize: 16),
),
),
// Controls overlay
if (_controller.isInitialized)
Positioned(
bottom: 40,
left: 24,
right: 24,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// Intensity label + value
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const Text(
'Milky intensity',
style: TextStyle(
color: Colors.white,
fontSize: 14,
fontWeight: FontWeight.w500,
),
),
Text(
'${(_intensity * 100).round()}%',
style: const TextStyle(
color: Colors.white70,
fontSize: 13,
),
),
],
),
const SizedBox(height: 8),
SliderTheme(
data: SliderTheme.of(context).copyWith(
activeTrackColor: Colors.white,
inactiveTrackColor: Colors.white30,
thumbColor: Colors.white,
overlayColor: Colors.white24,
),
child: Slider(
value: _intensity,
min: 0,
max: 1,
onChanged: (v) {
setState(() => _intensity = v);
_controller.setFilterIntensity(v);
},
),
),
],
),
),
],
),
),
);
}
}