### Install Flutter Extension from Local Path Source: https://context7.com/gemini-cli-extensions/flutter/llms.txt Use this command to install a downloaded Gemini CLI extension from a local path. Ensure you navigate to the temporary directory where the extension was extracted. ```bash cd %TEMP% cd gemini-extension123456 tar xvf win32.flutter.zip gemini extensions install --path %TEMP%\gemini-extension123456 ``` -------------------------------- ### Install Gemini CLI Flutter Extension Source: https://context7.com/gemini-cli-extensions/flutter/llms.txt Commands for installing, updating, and managing the Gemini CLI Flutter extension. Includes instructions for auto-update and a workaround for a known Windows installation issue. ```bash # Install the extension with auto-update enabled gemini extensions install https://github.com/gemini-cli-extensions/flutter.git --auto-update # Update to the latest version gemini extensions update flutter # Uninstall the extension gemini extensions uninstall flutter # Verify installation gemini extensions list # Windows workaround (for known installation issue): # 1. Attempt install (will fail) gemini extensions install https://github.com/gemini-cli-extensions/flutter.git ``` -------------------------------- ### Windows Extension Installation Workaround Source: https://github.com/gemini-cli-extensions/flutter/blob/main/README.md Workaround for installing extensions on Gemini CLI for Windows. This involves attempting the standard installation, navigating to the temporary download folder, unpacking a zip file, and then installing using the --path flag. ```bash gemini extensions install https://github.com/gemini-cli-extensions/flutter.git ``` ```bash cd %TEMP% ``` ```bash cd gemini-extension123456 ``` ```bash tar xvf win32.flutter.zip ``` ```bash gemini extensions install --path %TEMP%\gemini-extension123456 ``` -------------------------------- ### Install Flutter Extension from GitHub Source: https://github.com/gemini-cli-extensions/flutter/blob/main/README.md Installs the Gemini CLI Flutter extension directly from its GitHub repository. The --auto-update flag is optional and will automatically update the extension to new versions. ```bash gemini extensions install https://github.com/gemini-cli-extensions/flutter.git --auto-update ``` -------------------------------- ### Create New Flutter App Source: https://github.com/gemini-cli-extensions/flutter/blob/main/README.md Initiates a guided process to bootstrap a new Flutter application. It prompts for project details and location, then creates a project with recommended settings, linters, and starter files. ```bash /create-app I want to create a trip planning app ``` -------------------------------- ### Flutter go_router Setup for Navigation Source: https://github.com/gemini-cli-extensions/flutter/blob/main/flutter.md Configure go_router for declarative navigation and deep linking. Add the dependency, define routes with path parameters, and integrate with MaterialApp.router. ```dart // 1. Add the dependency // flutter pub add go_router // 2. Configure the router final GoRouter _router = GoRouter( routes: [ GoRoute( path: '/', builder: (context, state) => const HomeScreen(), routes: [ GoRoute( path: 'details/:id', // Route with a path parameter builder: (context, state) { final String id = state.pathParameters['id']!; return DetailScreen(id: id); }, ), ], ), ], ); // 3. Use it in your MaterialApp MaterialApp.router( routerConfig: _router, ); ``` -------------------------------- ### Modify Existing Code Source: https://github.com/gemini-cli-extensions/flutter/blob/main/README.md Starts a structured session to modify existing code. This command helps plan and execute changes by offering to create a git branch, generating design documents, and creating a phased implementation plan. ```bash /modify ``` -------------------------------- ### Update Flutter Extension Source: https://github.com/gemini-cli-extensions/flutter/blob/main/README.md Updates the installed Gemini CLI Flutter extension to the latest available version. ```bash gemini extensions update flutter ``` -------------------------------- ### Define TextTheme with Custom Fonts using google_fonts Source: https://github.com/gemini-cli-extensions/flutter/blob/main/flutter.md Add the google_fonts package and define a TextTheme to apply custom fonts consistently across your application. This example shows how to set different font styles for display, title, and body text. ```dart // 1. Add the dependency // flutter pub add google_fonts // 2. Define a TextTheme with a custom font final TextTheme appTextTheme = TextTheme( displayLarge: GoogleFonts.oswald(fontSize: 57, fontWeight: FontWeight.bold), titleLarge: GoogleFonts.roboto(fontSize: 22, fontWeight: FontWeight.w500), bodyMedium: GoogleFonts.openSans(fontSize: 14), ); ``` -------------------------------- ### Debug Complex Issues with /debug-app Source: https://context7.com/gemini-cli-extensions/flutter/llms.txt Initiates a systematic debugging process for complex Dart or Flutter application issues. It guides through creating a debugging plan and executing it step-by-step with user approval. ```bash # Start a debugging session /debug-app ``` -------------------------------- ### Create New Dart or Flutter Package Source: https://context7.com/gemini-cli-extensions/flutter/llms.txt Use /create-package to generate a new Dart or Flutter package following best practices. It includes documentation, implementation planning, and prompts for package specifics like pure Dart or Flutter-specific. ```bash /create-package I want to create a date parsing utility package ``` -------------------------------- ### Prepare and Execute Git Commits with /commit Source: https://context7.com/gemini-cli-extensions/flutter/llms.txt Automates pre-commit checks like code formatting, static analysis, and testing, then generates a Conventional Commits message. Run this command to prepare staged changes for a commit. ```bash # Run the commit command to prepare staged changes /commit ``` -------------------------------- ### Available MCP Tools via Dart Server Source: https://context7.com/gemini-cli-extensions/flutter/llms.txt Lists the development tools accessible through the Dart MCP server integrated with Gemini CLI. These tools assist in various aspects of Flutter and Dart development. ```bash # Available MCP tools through the Dart server: # - analyze_files: Run Dart analyzer for static analysis # - create_project: Create new Flutter/Dart projects # - dart_fix: Apply automated code fixes # - dart_format: Format Dart code # - pub: Manage package dependencies # - launch_app: Run Flutter applications # - list_devices: List available target devices # - run_tests: Execute test suites # - hot_reload: Reload running app with code changes # - get_widget_tree: Inspect widget hierarchy # - get_runtime_errors: Capture runtime exceptions # - set_widget_selection_mode: Enable widget selection # - get_selected_widget: Get details of selected widget # Connect to a running app via DTD URL: # 1. Run app with: flutter run --print-dtd # 2. Copy the DTD URL: ws://127.0.0.1:52636/M3G9d1Q3hFk= # 3. In Gemini CLI: "Connect to Flutter app with DTD URL: ws://..." ``` -------------------------------- ### Define Custom Theme Extension for Design Tokens Source: https://github.com/gemini-cli-extensions/flutter/blob/main/flutter.md Create a custom ThemeExtension to define reusable design tokens for styles not covered by standard ThemeData. Implement copyWith and lerp methods. ```dart // 1. Define the extension @immutable class MyColors extends ThemeExtension { const MyColors({required this.success, required this.danger}); final Color? success; final Color? danger; @override ThemeExtension copyWith({Color? success, Color? danger}) { return MyColors(success: success ?? this.success, danger: danger ?? this.danger); } @override ThemeExtension lerp(ThemeExtension? other, double t) { if (other is! MyColors) return this; return MyColors( success: Color.lerp(success, other.success, t), danger: Color.lerp(danger, other.danger, t), ); } } // 2. Register it in ThemeData theme: ThemeData( extensions: const >[ MyColors(success: Colors.green, danger: Colors.red), ], ), // 3. Use it in a widget Container( color: Theme.of(context).extension()!.success, ) ``` -------------------------------- ### Display Network Image with Loading and Error Handling Source: https://github.com/gemini-cli-extensions/flutter/blob/main/flutter.md Use Image.network to display images from a URL. Always include loadingBuilder and errorBuilder for a better user experience, especially providing an errorBuilder. ```dart // When using network images, always provide an errorBuilder. Image.network( 'https://picsum.photos/200/300', loadingBuilder: (context, child, progress) { if (progress == null) return child; return const Center(child: CircularProgressIndicator()); }, errorBuilder: (context, error, stackTrace) { return const Icon(Icons.error); }, ) ``` -------------------------------- ### Print Dart Tooling Daemon URI Source: https://github.com/gemini-cli-extensions/flutter/blob/main/README.md Run this command to print the Dart Tooling Daemon URI for connecting to a running Flutter app. This is useful for debugging and development. ```bash $ flutter run --print-dtd ``` -------------------------------- ### Run Commit Command Source: https://github.com/gemini-cli-extensions/flutter/blob/main/README.md Use this command to prepare staged git changes for a commit. It automatically formats code, runs the analyzer, executes tests, and generates a commit message. ```bash /commit ``` -------------------------------- ### Gemini Extension Configuration for Dart MCP Server Source: https://context7.com/gemini-cli-extensions/flutter/llms.txt Configuration file for a Gemini CLI extension, enabling integration with the Dart MCP server. This allows access to development tools directly within the Gemini CLI. ```json // gemini-extension.json configuration { "name": "flutter", "description": "Enables several Flutter and Dart-related commands and context.", "version": "0.4.1", "contextFileName": "flutter.md", "mcpServers": { "dart": { "command": "dart", "args": ["mcp-server"] } } } ``` -------------------------------- ### Run Build Runner for Code Generation Source: https://github.com/gemini-cli-extensions/flutter/blob/main/flutter.md Execute this command after modifying files that require code generation, such as those used with json_serializable. Ensure build_runner is a dev dependency. ```shell dart run build_runner build --delete-conflicting-outputs ``` -------------------------------- ### OverlayPortal for Custom UI Elements Source: https://github.com/gemini-cli-extensions/flutter/blob/main/flutter.md Implement a custom dropdown or tooltip using OverlayPortal. This widget manages OverlayEntry to display UI elements above other content, controlled by an OverlayPortalController. ```dart class MyDropdown extends StatefulWidget { const MyDropdown({super.key}); @override State createState() => _MyDropdownState(); } class _MyDropdownState extends State { final _controller = OverlayPortalController(); @override Widget build(BuildContext context) { return OverlayPortal( controller: _controller, overlayChildBuilder: (BuildContext context) { return const Positioned( top: 50, left: 10, child: Card( child: Padding( padding: EdgeInsets.all(8.0), child: Text('I am an overlay!'), ), ), ); }, child: ElevatedButton( onPressed: _controller.toggle, child: const Text('Toggle Overlay'), ), ); } } ``` -------------------------------- ### Define Light Theme with ColorScheme.fromSeed Source: https://github.com/gemini-cli-extensions/flutter/blob/main/flutter.md Create a ThemeData object for a light theme, generating a harmonious color palette from a single seed color. This is useful for ensuring consistent application-wide styling. ```dart final ThemeData lightTheme = ThemeData( colorScheme: ColorScheme.fromSeed( seedColor: Colors.deepPurple, brightness: Brightness.light, ), // ... other theme properties ); ``` -------------------------------- ### Configure Dart Lint Rules Source: https://github.com/gemini-cli-extensions/flutter/blob/main/flutter.md Include the flutter_lints package in your analysis_options.yaml file to enforce a set of recommended Dart lint rules. Customize rules by uncommenting or adding them. ```yaml include: package:flutter_lints/flutter.yaml linter: rules: # Add additional lint rules here: # avoid_print: false # prefer_single_quotes: true ``` -------------------------------- ### Define Light and Dark Themes with ThemeData Source: https://github.com/gemini-cli-extensions/flutter/blob/main/flutter.md Configure light and dark themes for your MaterialApp using ThemeData. Use ColorScheme.fromSeed for harmonious color palettes and define text styles. ```dart // main.dart MaterialApp( theme: ThemeData( colorScheme: ColorScheme.fromSeed( seedColor: Colors.deepPurple, brightness: Brightness.light, ), textTheme: const TextTheme( displayLarge: TextStyle(fontSize: 57.0, fontWeight: FontWeight.bold), bodyMedium: TextStyle(fontSize: 14.0, height: 1.4), ), ), darkTheme: ThemeData( colorScheme: ColorScheme.fromSeed( seedColor: Colors.deepPurple, brightness: Brightness.dark, ), ), home: const MyHomePage(), ); ``` -------------------------------- ### Uninstall Flutter Extension Source: https://github.com/gemini-cli-extensions/flutter/blob/main/README.md Uninstalls the Gemini CLI Flutter extension from your system. ```bash gemini extensions uninstall flutter ``` -------------------------------- ### Declare Flutter Assets in pubspec.yaml Source: https://github.com/gemini-cli-extensions/flutter/blob/main/flutter.md Declare all asset paths in your pubspec.yaml file to make them available to your Flutter application. ```yaml flutter: uses-material-design: true assets: - assets/images/ ``` -------------------------------- ### Dart Structured Logging with dart:developer Source: https://github.com/gemini-cli-extensions/flutter/blob/main/flutter.md Employ structured logging using the `log` function from `dart:developer` for integration with Dart DevTools. Supports simple messages, error logging with levels, and stack traces. ```dart import 'dart:developer' as developer; // For simple messages developer.log('User logged in successfully.'); // For structured error logging try { // ... code that might fail } catch (e, s) { developer.log( 'Failed to fetch data', name: 'myapp.network', level: 1000, // SEVERE error: e, stackTrace: s, ); } ``` -------------------------------- ### Display Local Image in Flutter Source: https://github.com/gemini-cli-extensions/flutter/blob/main/flutter.md Use Image.asset to display local images from your asset bundle. Ensure the asset path is correctly declared in pubspec.yaml. ```dart Image.asset('assets/images/placeholder.png') ``` -------------------------------- ### Button Style with WidgetStateProperty Source: https://github.com/gemini-cli-extensions/flutter/blob/main/flutter.md Define a button style that changes its background color when pressed. This uses WidgetStateProperty.resolveWith to conditionally apply colors based on the widget's state. ```dart final ButtonStyle myButtonStyle = ButtonStyle( backgroundColor: WidgetStateProperty.resolveWith( (Set states) { if (states.contains(WidgetState.pressed)) { return Colors.green; // Color when pressed } return Colors.red; // Default color }, ), ); ``` -------------------------------- ### Flutter Text Theme Configuration Source: https://github.com/gemini-cli-extensions/flutter/blob/main/flutter.md Configure the TextTheme in ThemeData to define typographic styles for your Flutter application. This includes font sizes and weights for various text elements. ```dart // In your ThemeData textTheme: const TextTheme( displayLarge: TextStyle(fontSize: 57.0, fontWeight: FontWeight.bold), titleLarge: TextStyle(fontSize: 22.0, fontWeight: FontWeight.bold), bodyLarge: TextStyle(fontSize: 16.0, height: 1.5), bodyMedium: TextStyle(fontSize: 14.0, height: 1.4), labelSmall: TextStyle(fontSize: 11.0, color: Colors.grey), ), ``` -------------------------------- ### Dart JSON Serialization with Field Renaming Source: https://github.com/gemini-cli-extensions/flutter/blob/main/flutter.md Implement JSON serialization and encoding using json_serializable and json_annotation. Use fieldRename: FieldRename.snake for converting Dart camelCase to JSON snake_case. ```dart // In your model file import 'package:json_annotation/json_annotation.dart'; part 'user.g.dart'; @JsonSerializable(fieldRename: FieldRename.snake) class User { final String firstName; final String lastName; User({required this.firstName, required this.lastName}); factory User.fromJson(Map json) => _$UserFromJson(json); Map toJson() => _$UserToJson(this); } ``` -------------------------------- ### Flutter Navigator for Screen Navigation Source: https://github.com/gemini-cli-extensions/flutter/blob/main/flutter.md Utilize the built-in Navigator for short-lived screens like dialogs or temporary views that do not require deep linking. Push new screens or pop the current one. ```dart // Push a new screen onto the stack Navigator.push( context, MaterialPageRoute(builder: (context) => const DetailsScreen()), ); // Pop the current screen to go back Navigator.pop(context); ``` -------------------------------- ### Flutter ValueNotifier for Simple State Source: https://github.com/gemini-cli-extensions/flutter/blob/main/flutter.md Use ValueNotifier with ValueListenableBuilder for simple, local state involving a single value. It listens for changes and rebuilds the UI accordingly. ```dart // Define a ValueNotifier to hold the state. final ValueNotifier _counter = ValueNotifier(0); // Use ValueListenableBuilder to listen and rebuild. ValueListenableBuilder( valueListenable: _counter, builder: (context, value, child) { return Text('Count: $value'); }, ); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.