Skip to content

[Bug]: genai package has unnecessary Flutter SDK dependency preventing pure-Dart CLI usage #1591

@soumyarajbag

Description

@soumyarajbag

Describe the bug/problem

Please describe the bug/problem here

The genai package currently has a hard dependency on the Flutter SDK. In its pubspec.yaml, it requires:

flutter:
  sdk: flutter

Additionally, ai_request_utils.dart imports package:flutter/foundation.dart solely to use debugPrint.

While similar issues were addressed for better_networking (e.g., #1360), this problem still exists in the genai package. This tight coupling to Flutter prevents the package from being used in pure Dart environments and blocks batch evaluation runs in headless Dart/CLI contexts.


Steps to Reproduce the bug/problem

Please provide the steps to reproduce the behaviour. Screenshot(s)/image(s) are preferred to help explain it better

  1. Create a pure Dart CLI application or package (without Flutter).

  2. Add the genai package from this workspace as a dependency.

  3. Run:

    dart pub get
  4. Attempt to run a Dart script.

Result:

  • It fails because the Flutter SDK is not available, or

  • Compilation fails due to the import:

    import 'package:flutter/foundation.dart';

Expected behavior

Description of what you expected to happen

The genai package should be a pure Dart library without any dependency on the Flutter SDK.

Utilities like debugPrint should be replaced with:

  • print
  • dart:developer's log()
  • or a dedicated logging package

This would allow seamless usage in Dart CLI, backend services, and other non-Flutter environments.


Device Info (The device where you encountered this issue)

  • OS: MacOS (Applies to all Operating Systems)
  • Version: Not Platform Specific
  • Browser (only if you encountered the issue while running the web app): N/A

Flutter Doctor

Please run the flutter doctor -v command and provide the details below:

# N/A - Architectural/Dependency issue.
[✓] Flutter (Channel stable)
[✓] Dart SDK version: 3.x

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    In progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions