Loading skill
Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Use when setting up firebase_ai, generating text/chat with Gemini, streaming AI output, building multimodal prompts, or handling AI errors.
.claude/skills/evanca-firebase-ai/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | -3% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 18% | 0% |
| case-04 | ✗→✓ | ▲ Improved | -2% | 0% |
| case-06 | ✗→✓ | ▲ Improved | -27% | 0% |
| case-08 | ✗→✓ | ▲ Improved | -15% | 0% |
This skill defines how to correctly use Firebase AI Logic in Flutter applications.
Use this skill when:
flutter pub add firebase_aidartimport 'package:firebase_ai/firebase_ai.dart'; import 'package:firebase_core/firebase_core.dart'; import 'firebase_options.dart'; // Initialize FirebaseApp await Firebase.initializeApp( options: DefaultFirebaseOptions.currentPlatform, ); // Initialize the Gemini Developer API backend service final model = FirebaseAI.googleAI().generativeModel(model: 'gemini-2.5-flash');
FirebaseAI.googleAI() for the Gemini Developer API backend (recommended starting point).Platform support:
| Platform | Support | |---|---| | iOS | Full | | Android | Full | | Web | Full | | macOS / other Apple | Beta | | Windows | Not supported |
dartfinal response = await model.generateContent([ Content.text('Summarize the benefits of Flutter for mobile development'), ]); final text = response.text; // The generated summary string
dartfinal chat = model.startChat(); final response = await chat.sendMessage( Content.text('What is the difference between StatelessWidget and StatefulWidget?'), ); print(response.text); // Follow-up in the same conversation final followUp = await chat.sendMessage( Content.text('When should I use StatefulWidget?'), ); print(followUp.text);
Use streaming to display partial results as they arrive:
dartfinal stream = model.generateContentStream([ Content.text('Write a step-by-step guide to implementing dark mode in Flutter'), ]); await for (final chunk in stream) { // Append chunk.text to the UI progressively setState(() => _output += chunk.text ?? ''); }
dartfinal imageBytes = await File('photo.jpg').readAsBytes(); final response = await model.generateContent([ Content.multi([ TextPart('Describe what you see in this image'), InlineDataPart('image/jpeg', imageBytes), ]), ]);
Wrap AI calls in structured error handling:
darttry { final response = await model.generateContent([Content.text(prompt)]); return response.text; } on FirebaseAIException catch (e) { if (e.message?.contains('quota') ?? false) { // Handle rate limiting — show retry message or queue the request return 'Service is busy. Please try again shortly.'; } return 'AI service error: ${e.message}'; } catch (e) { return 'Unexpected error: $e'; }
dartfinal model = FirebaseAI.googleAI().generativeModel( model: 'gemini-2.5-flash', safetySettings: [ SafetySetting(HarmCategory.harassment, HarmBlockThreshold.medium), SafetySetting(HarmCategory.dangerousContent, HarmBlockThreshold.high), ], );
Other measured skills in the registry, with their headline benchmark lift.