Closed as not planned
Closed as not planned
Description
Platform
Web (chrome & Edge)
Plugin
package_info_plus
Version
3.0.2 (latest)
Flutter SDK
3.3.10
Steps to reproduce
Run the sample code on flutter web deployed as chrome extension
Deploying as chrome extension:
- Run
flutter build web --release --web-renderer html --csp
- In Chrome/Edge go to the extensions page (
chrome://extensions
oredge://extensions
). - Enable Developer Mode.
- Load the build/web directory to your browser.
- Open new tab and check the text.
- Instead of printing the version on screen, there's an error:
FILE_NOT_FOUND
in the console and it never shows the version.
If the same thing is done with a normal run of the project with flutter run web
then it works perfectly. It just doesn't work on web builds deployed as browser extension.
According to the error in. the console, it seems like the base uri for version.json
file is incorrect in this case.
Code Sample
### main.dart
import 'package:flutter/material.dart';
import 'package:package_info_plus/package_info_plus.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: MyWidget(),
),
),
);
}
}
class MyWidget extends StatefulWidget {
const MyWidget({super.key});
@override
State<MyWidget> createState() => _MyWidgetState();
}
class _MyWidgetState extends State<MyWidget> {
String? version;
@override
void initState() {
super.initState();
fetchVersion();
}
@override
Widget build(BuildContext context) {
return Text(
version ?? 'Loading...',
style: Theme.of(context).textTheme.headline4,
);
}
Future<void> fetchVersion() async {
final PackageInfo info = await PackageInfo.fromPlatform();
setState(() => version = info.version);
}
}
### web/manifest.json
```json
{
"name": "Test Project",
"description": "A is a description.",
"version": "0.1.1",
"manifest_version": 3,
"short_name": "test",
"content_security_policy": {
"content_security_policy": {
"extension_pages": "script-src 'self' ; object-src 'self'"
}
},
"chrome_url_overrides": {
"newtab": "index.html"
},
"icons": {
"128": "icon128.png"
}
}
### Logs
```shell
GET chrome-extension://nfdiokdbeccelflpphpogdaendmlkfoi/index.html/version.json?cachebuster=1671427592603 net::ERR_FILE_NOT_FOUND
Flutter Doctor
[✓] Flutter (Channel stable, 3.3.10, on macOS 13.1 22C65 darwin-arm, locale en-IN)
• Flutter version 3.3.10 on channel stable at /Users/birjuvachhani/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 135454af32 (4 days ago), 2022-12-15 07:36:55 -0800
• Engine revision 3316dd8728
• Dart version 2.18.6
• DevTools version 2.15.0
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc1)
• Android SDK at /Users/birjuvachhani/Library/Android/sdk
• Platform android-33, build-tools 33.0.0-rc1
• Java binary at: /Users/birjuvachhani/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/213.7172.25.2113.9123335/Android Studio.app/Contents/jre/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 14C18
• CocoaPods version 1.11.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2021.3)
• Android Studio at /Users/birjuvachhani/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/213.7172.25.2113.9014738/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 11.0.13+0-b1751.21-8125866)
[✓] Android Studio (version 2021.3)
• Android Studio at /Users/birjuvachhani/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/213.7172.25.2113.9123335/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 11.0.13+0-b1751.21-8125866)
[✓] IntelliJ IDEA Community Edition (version 2022.2.3)
• IntelliJ at /Users/birjuvachhani/Library/Application Support/JetBrains/Toolbox/apps/IDEA-C/ch-0/222.4345.14/IntelliJ IDEA CE.app
• 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
[✓] IntelliJ IDEA Community Edition (version 2022.3)
• IntelliJ at /Users/birjuvachhani/Library/Application Support/JetBrains/Toolbox/apps/IDEA-C/ch-0/223.7571.182/IntelliJ IDEA CE.app
• 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
[✓] VS Code (version 1.74.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.52.0
[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-arm64 • macOS 13.1 22C65 darwin-arm
• Chrome (web) • chrome • web-javascript • Google Chrome 108.0.5359.124
[✓] HTTP Host Availability
• All required HTTP hosts are available
• No issues found!
Checklist before submitting a bug
- I Google'd a solution and I couldn't find it
- I searched on StackOverflow for a solution and I couldn't find it
- I read the README.md file of the plugin
- I'm using the latest version of the plugin
- All dependencies are up to date with
flutter pub upgrade
- I did a
flutter clean
- I tried running the example project