ai_edge_sdk 1.0.0 copy "ai_edge_sdk: ^1.0.0" to clipboard
ai_edge_sdk: ^1.0.0 copied to clipboard

PlatformAndroid

Flutter plugin for Google's AI Edge SDK, enabling on-device generative AI with Gemini Nano on Android devices.

example/lib/main.dart

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

import 'package:ai_edge_sdk/ai_edge_sdk.dart';

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

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

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

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';
  final _aiEdgeSdk = AiEdgeSdk();

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  // Check device support and get device info
  Future<void> initPlatformState() async {
    String platformVersion;
    try {
      final deviceInfo = await _aiEdgeSdk.getDeviceInfo();
      final isSupported = await _aiEdgeSdk.isSupported();
      
      platformVersion = 'Device: ${deviceInfo.manufacturer} ${deviceInfo.model}\n'
                       'Android: ${deviceInfo.androidVersion}\n'
                       'Pixel 9 Series: ${deviceInfo.isPixel9Series}\n'
                       'AICore Available: ${deviceInfo.isAiCoreAvailable}\n'
                       'Supported: $isSupported\n'
                       'Status: ${deviceInfo.compatibilityStatus}';
    } on Exception catch (e) {
      platformVersion = 'Error: $e';
    }

    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Padding(
          padding: const EdgeInsets.all(16.0),
          child: Center(
            child: Text(
              _platformVersion,
              textAlign: TextAlign.center,
              style: const TextStyle(fontSize: 14),
            ),
          ),
        ),
      ),
    );
  }
}
0
likes
140
points
25
downloads

Publisher

verified publisheramorelli.tech

Weekly Downloads

Flutter plugin for Google's AI Edge SDK, enabling on-device generative AI with Gemini Nano on Android devices.

Repository (GitHub)
View/report issues

Topics

#artificial-intelligence #machine-learning #gemini #on-device-ai #text-generation

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on ai_edge_sdk

Packages that implement ai_edge_sdk