-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
flutter/packages
#8611Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listfound in release: 3.27Found to occur in 3.27Found to occur in 3.27found in release: 3.29Found to occur in 3.29Found to occur in 3.29has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: cross_fileThe cross_file pluginThe cross_file pluginpackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.platform-webWeb applications specificallyWeb applications specificallyteam-ecosystemOwned by Ecosystem teamOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem teamTriaged by Ecosystem team
Description
Steps to reproduce
XFile.fromData on Web reads the file at given path instead of returning the bytes given to it in constructor. Works as expected on other platforms (I checked macOS only).
- Run the given sample on platform other than web (I used macOS).
- Notice that it shows "Hello World" text in UI which is correct and expected.
- Now run it on web.
- Notice that instead of showing "Hello World", it shows actual contents of the
lib/main.dartfile.
Expected results
It should read "Hello World" as text when calling file.readAsString() on all platforms.
Actual results
I reads the file at given path instead of returning the given bytes on web.
Code sample
Code sample
import 'dart:convert';
import 'package:cross_file/cross_file.dart';
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
XFile? file;
@override
void initState() {
super.initState();
file = XFile.fromData(
utf8.encode('Hello World'),
path: 'lib/main.dart',
name: 'main.dart',
length: 11,
mimeType: 'text/plain',
lastModified: DateTime.now(),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: Center(
child: FutureBuilder(
future: file?.readAsString(),
builder: (context, snapshot) {
if (!snapshot.hasData) {
return const CircularProgressIndicator();
}
return Text(snapshot.data ?? 'No data');
},
),
),
);
}
}
Screenshots or Video
Logs
MacOS Logs
2025-02-11 18:07:11.385 cross_file_test[6170:4508767] _TIPropertyValueIsValid called with 16 on nil context!
2025-02-11 18:07:11.385 cross_file_test[6170:4508767] imkxpc_getApplicationProperty:reply: called with incorrect property value 16, bailing.
2025-02-11 18:07:11.385 cross_file_test[6170:4508767] Text input context does not respond to _valueForTIProperty:Web Logs
Launching lib/main.dart on Chrome in debug mode...
Waiting for connection from debug service on Chrome...
This app is linked to the debug service: ws://127.0.0.1:62549/W2h_3uW-lDo=/ws
Debug service listening on ws://127.0.0.1:62549/W2h_3uW-lDo=/ws
Debug service listening on ws://127.0.0.1:62549/W2h_3uW-lDo=/wsFlutter Doctor output
Doctor output
[✓] Flutter (Channel stable, 3.27.3, on macOS 15.3 24D60 darwin-arm64, locale en-IN)
• Flutter version 3.27.3 on channel stable at /Users/birjuvachhani/.puro/envs/stable/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision c519ee916e (3 weeks ago), 2025-01-21 10:32:23 -0800
• Engine revision e672b006cb
• Dart version 3.6.1
• DevTools version 2.40.2
[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
• Android SDK at /Users/birjuvachhani/Library/Android/sdk
• Platform android-35, build-tools 35.0.0
• ANDROID_HOME = /Users/birjuvachhani/Library/Android/sdk
• Java binary at: /Users/birjuvachhani/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 21.0.4+-12422083-b607.1)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 16.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 16C5032a
• CocoaPods version 1.16.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2024.2)
• Android Studio at /Users/birjuvachhani/Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 21.0.4+-12422083-b607.1)
[✓] IntelliJ IDEA Community Edition (version 2024.3.2.2)
• IntelliJ at /Users/birjuvachhani/Applications/IntelliJ IDEA Community Edition.app
• Flutter plugin version 83.0.4
• Dart plugin version 243.23654.44
[✓] VS Code (version 1.96.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.102.0
[✓] Connected device (3 available)
• macOS (desktop) • macos • darwin-arm64 • macOS 15.3 24D60 darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 15.3 24D60 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 132.0.6834.160
! Error: Browsing on the local area network for Birju’s iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac.
The device must be opted into Developer Mode to connect wirelessly. (code -27)
[✓] Network resources
• All expected network resources are available.
• No issues found!
DAAAAAAAAAAAAAAAAN and atn832
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listfound in release: 3.27Found to occur in 3.27Found to occur in 3.27found in release: 3.29Found to occur in 3.29Found to occur in 3.29has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: cross_fileThe cross_file pluginThe cross_file pluginpackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.platform-webWeb applications specificallyWeb applications specificallyteam-ecosystemOwned by Ecosystem teamOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem teamTriaged by Ecosystem team

