text:
Successive calls to precacheImage() throw an exception

Steps to Reproduce

Call precacheImage(const NetworkImage('https://via.placeholder.com/350x150'), context);
Wait a few seconds, allowing for the image to cache.
Call the same line of code.

I found this easiest to reproduce by placing the line of code in a IconButton's onPressed handler. Pressing the button the first time works fine, but pressing it a second time consistently produces the following error.
For added context, package:Checkiday/main.dart:270:15 in the below logs is the line of code above.
Logs
[+7803 ms] I/flutter ( 9077): ══╡ EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE ╞════════════════════════════════════════════════════
[   +8 ms] I/flutter ( 9077): The following StateError was thrown by an image error listener:
[        ] I/flutter ( 9077): Bad state: Future already completed
[  +10 ms] I/flutter ( 9077):
[        ] I/flutter ( 9077): When the exception was thrown, this was the stack:
[  +10 ms] I/flutter ( 9077): #1      precacheImage.errorListener (package:flutter/src/widgets/image.dart:88:15)
[        ] I/flutter ( 9077): #2      ImageStreamCompleter.reportError (package:flutter/src/painting/image_stream.dart:327:24)
[        ] I/flutter ( 9077): #3      ImageStreamCompleter.setImage (package:flutter/src/painting/image_stream.dart:284:9)
[        ] I/flutter ( 9077): #4      MultiFrameImageStreamCompleter._emitFrame (package:flutter/src/painting/image_stream.dart:519:5)
[        ] I/flutter ( 9077): #5      MultiFrameImageStreamCompleter._decodeNextFrameAndSchedule (package:flutter/src/painting/image_stream.dart:512:7)
[        ] I/flutter ( 9077): <asynchronous suspension>
[        ] I/flutter ( 9077): #6      MultiFrameImageStreamCompleter.addListener (package:flutter/src/painting/image_stream.dart:528:7)
[        ] I/flutter ( 9077): #7      ImageStream.addListener (package:flutter/src/painting/image_stream.dart:156:25)
[        ] I/flutter ( 9077): #8      precacheImage (package:flutter/src/widgets/image.dart:101:10)
[        ] I/flutter ( 9077): #9      _HomePageState.build.<anonymous closure> (package:Checkiday/main.dart:270:15)
[        ] I/flutter ( 9077): #10     _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:507:14)
[        ] I/flutter ( 9077): #11     _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:562:30)
[        ] I/flutter ( 9077): #12     GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
[        ] I/flutter ( 9077): #13     TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:242:9)
[        ] I/flutter ( 9077): #14     TapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:204:7)
[        ] I/flutter ( 9077): #15     GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:156:27)
[        ] I/flutter ( 9077): #16     _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:184:20)
[        ] I/flutter ( 9077): #17     _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:158:22)
[        ] I/flutter ( 9077): #18     _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:138:7)
[        ] I/flutter ( 9077): #19     _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:101:7)
[        ] I/flutter ( 9077): #20     _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:85:7)
[        ] I/flutter ( 9077): #21     _invoke1 (dart:ui/hooks.dart:168:13)
[        ] I/flutter ( 9077): #22     _dispatchPointerDataPacket (dart:ui/hooks.dart:122:5)
[        ] I/flutter ( 9077): (elided one frame from package dart:async)
[        ] I/flutter ( 9077): ════════════════════════════════════════════════════════════════════════════════════════════════════

[✓] Flutter (Channel stable, v1.0.0, on Linux, locale en_US.UTF-8)
    • Flutter version 1.0.0 at /home/westy92/Source/flutter
    • Framework revision 5391447fae (10 days ago), 2018-11-29 19:41:26 -0800
    • Engine revision 7375a0f414
    • Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)

[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
    • Android SDK at /home/westy92/Android/Sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: /home/westy92/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
    • All Android licenses accepted.

[✓] Android Studio (version 3.2)
    • Android Studio at /home/westy92/android-studio
    • Flutter plugin version 31.1.1
    • Dart plugin version 181.5656
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)

[✓] VS Code (version 1.28.0)
    • VS Code at /usr/share/code
    • Flutter extension version 2.21.1

[✓] Connected device (1 available)
    • Pixel • FA69H0305733 • android-arm64 • Android 9 (API 28)

• No issues found!

@zoechi attached is a minimal lib/main.dart as requested.
import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key}) : super(key: key);

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          precacheImage(const NetworkImage('https://via.placeholder.com/350x150'), context);
        },
        child: Icon(Icons.image),
      ),
    );
  }
}

Reproduction steps are still about the same.

Tap the FAB.
Wait a few seconds for the image to cache.
Tap the FAB.

Stacktrace with this minimal example:
I/flutter (24987): ══╡ EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE ╞════════════════════════════════════════════════════
I/flutter (24987): The following StateError was thrown by an image error listener:
I/flutter (24987): Bad state: Future already completed
I/flutter (24987):
I/flutter (24987): When the exception was thrown, this was the stack:
I/flutter (24987): #1      precacheImage.errorListener (package:flutter/src/widgets/image.dart:88:15)
I/flutter (24987): #2      ImageStreamCompleter.reportError (package:flutter/src/painting/image_stream.dart:327:24)
I/flutter (24987): #3      ImageStreamCompleter.setImage (package:flutter/src/painting/image_stream.dart:284:9)
I/flutter (24987): #4      MultiFrameImageStreamCompleter._emitFrame (package:flutter/src/painting/image_stream.dart:519:5)
I/flutter (24987): #5      MultiFrameImageStreamCompleter._decodeNextFrameAndSchedule (package:flutter/src/painting/image_stream.dart:512:7)
I/flutter (24987): <asynchronous suspension>
I/flutter (24987): #6      MultiFrameImageStreamCompleter.addListener (package:flutter/src/painting/image_stream.dart:528:7)
I/flutter (24987): #7      ImageStream.addListener (package:flutter/src/painting/image_stream.dart:156:25)
I/flutter (24987): #8      precacheImage (package:flutter/src/widgets/image.dart:101:10)
I/flutter (24987): #9      _MyHomePageState.build.<anonymous closure> (package:flutter_local_test/main.dart:29:11)
I/flutter (24987): #10     _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:507:14)
I/flutter (24987): #11     _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:562:30)
I/flutter (24987): #12     GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24)
I/flutter (24987): #13     TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:242:9)
I/flutter (24987): #14     TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:175:7)
I/flutter (24987): #15     PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:315:9)
I/flutter (24987): #16     PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:73:12)
I/flutter (24987): #17     PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101:11)
I/flutter (24987): #18     _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:180:19)
I/flutter (24987): #19     _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:158:22)
I/flutter (24987): #20     _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:138:7)
I/flutter (24987): #21     _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:101:7)
I/flutter (24987): #22     _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:85:7)
I/flutter (24987): #23     _invoke1 (dart:ui/hooks.dart:168:13)
I/flutter (24987): #24     _dispatchPointerDataPacket (dart:ui/hooks.dart:122:5)
I/flutter (24987): (elided one frame from package dart:async)
I/flutter (24987): ════════════════════════════════════════════════════════════════════════════════════════════════════

package:flutter/src/widgets/image.dart:101
  stream.addListener(listener, onError: errorListener);
  completer.future.then<void>((void value) { stream.removeListener(listener); });

when we remove listener, we should remove errorListener as well. I'm making test case for this

I tracked down and fix the problem from @westy92 's example, but haven't figured out the unit test for it #25159

possibly related
packages/flutter/lib/src/painting/image_stream.dart:224
  /// If the [ImageStreamCompleter] completes multiple images over its lifetime,
  /// this listener will fire multiple times.

unit test added for #25159

source: gharchive/issue

repo: flutter/flutter

license_type: permissive

license_source: github-api


text:
How to share Fonts used in flutter with Native Code

I have a build a flutter plugin and I want to use the font used in the app to be applied within my plugin
Is there a way to achieve this

Without additional information, we are unfortunately not sure how to resolve this issue. We are therefore reluctantly going to close this bug for now. Please don't hesitate to comment on the bug if you have any more information for us; we will reopen it right away!
Thanks for your contribution.
Could everyone who still has this problem please file a new issue with the exact descriptions what happens, logs and the output of 'flutter doctor -v'  please.
All system setups can be slightly different so it's always better to open new issues and reference related issues.

op is talking about this plugin
https://github.com/PonnamKarthik/FlutterToast
he wants to pass font as a style to fluttre.jar I suppose.

authors: Ham3D PonnamKarthik iapicca


text:
CupertinoSliverRefreshControl doesn't work on android

CupertinoSliverRefreshControl working fine on ios, but android cant recognize this widget
code :
class MainScreenView extends StatelessWidget{

  build(context) {
    return CupertinoTabView(
      builder: (context){
        return CustomScrollView(
          slivers: [
            CupertinoSliverNavigationBar(
              largeTitle: const Text("Hot news"),
            ),
            CupertinoSliverRefreshControl(
              onRefresh: () {
                return Future.delayed(const Duration(seconds: 3)).then((_) {

                });
              },
            ),
          ],
        );
      },
    );
  }
}

[✓] Flutter (Channel master, v1.2.1-pre.142, on Mac OS X 10.14.2 18C54, locale ru-RU)
    • Flutter version 1.2.1-pre.142 at /Users/daniel/crossplatform/flutter
    • Framework revision fec01201b1 (5 days ago), 2019-02-09 11:23:28 -0500
    • Engine revision 067045757f
    • Dart version 2.1.2 (build 2.1.2-dev.0.0 174d6fec3d)

[!] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/daniel/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses

[!] iOS toolchain - develop for iOS devices (Xcode 10.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.1, Build version 10B61
    ✗ libimobiledevice and ideviceinstaller are not installed. To install with Brew, run:
        brew update
        brew install --HEAD usbmuxd
        brew link usbmuxd
        brew install --HEAD libimobiledevice
        brew install ideviceinstaller
    ✗ ios-deploy not installed. To install:
        brew install ios-deploy
    • CocoaPods version 1.5.3

[✓] Android Studio (version 3.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 31.3.1
    • Dart plugin version 181.5656
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)

[✓] Connected device (2 available)
    • FS8009                    • VN3GLMA751202014 • android-arm64 • Android 7.0 (API 24)
    • Android SDK built for x86 • emulator-5554    • android-x86   • Android 9 (API 28) (emulator)

! Doctor found issues in 2 categories.
Process finished with exit code 0

To investigate we would need a minimal runnable reproduction
as a single file so that we can just copy your code into lib/main.dart of a new project and run to reproduce.

To investigate we would need a minimal runnable reproduction
as a single file so that we can just copy your code into lib/main.dart of a new project and run to reproduce.

no problem

In the gallery app itself on Android the widget doesn't work

Can you please explain what steps to take to reproduce or upload a video https://github.com/flutter/flutter/wiki/Making-animated-GIFs-of-Flutter-apps?

@Renesanse This is working as intended. It's due to the ScrollPhysics which is used on Android. iOS uses BouncingScrollPhysics which doesn't apply any boundary conditions when applyBoundaryConditions is called i.e. it allows for under/overscrolling. If you want the same effect on Android you can use BouncingScrollPhysics which will give you the an iOS feel on Android, or you can override ClampingScrollPhysics which is what Android uses.
Here's how I did it:
class CustomClampingScrollPhysics extends ClampingScrollPhysics {

  const CustomClampingScrollPhysics({
    ScrollPhysics parent,
    this.canUnderscroll = false,
    this.canOverscroll = false,
  }) : super(parent: parent);

  final bool canUnderscroll;

  final bool canOverscroll;

  @override
  CustomClampingScrollPhysics applyTo(ScrollPhysics ancestor) {
    return CustomClampingScrollPhysics(
      parent: buildParent(ancestor),
      canUnderscroll: canUnderscroll,
      canOverscroll: canOverscroll
    );
  }

  /// Removes the overscroll and underscroll conditions from the original
  /// [ClampingScrollPhysics.applyBoundaryConditions].
  @override
  double applyBoundaryConditions(ScrollMetrics position, double value) {
    if (value < position.pixels && position.pixels <= position.minScrollExtent) // underscroll
      return canUnderscroll ? 0.0 : value - position.pixels;
    if (position.maxScrollExtent <= position.pixels && position.pixels < value) // overscroll
      return canOverscroll ? 0.0 : value - position.pixels;
    if (value < position.minScrollExtent && position.minScrollExtent < position.pixels) // hit top edge
      return value - position.minScrollExtent;
    if (position.pixels < position.maxScrollExtent && position.maxScrollExtent < value) // hit bottom edge
      return value - position.maxScrollExtent;
    return 0.0;
  }
}

This will give you the Android scrolling behavior, but will allow for over/underscrolling whenever you drag past an edge. For your case I would enable canUnderscroll and disable canOverscroll.

Thank you so much! You solve my problem.

Thank you so much! You solve my problem.

authors: Renesanse dcov vladir95 zoechi


text:
Feature Request: Multi-platform flutter installs

I am a user of the flutter-desktop-embedding project and thrilled with the possibility of cross-platform app development from a single dev workstation.
I ran into an issue when trying to use the same shared filesystem to develop a macOS and Windows app -- in summary, when running flutter for the first time, a bin/cache directory is populated with the appropriate Dart SDK for the detected platform. Unfortunately when re-using the same flutter installation directory from a different platform (e.g. macOS -> Windows), the bin/cache directory is invalid for that architecture.
https://github.com/google/flutter-desktop-embedding/issues/292
I would like a multi-platform way to use the exact same flutter release directory for multiple platforms which have mounted a shared filesystem.

Does flutter precache  --all-platforms do what you want?
jonahwilliams-macbookpro2:demo_example jonahwilliams$ flutter precache -h -v
Populates the Flutter tool's cache of binary artifacts.

Usage: flutter precache [arguments]
-h, --help             Print this usage information.
-a, --all-platforms    Precache artifacts for all platforms.

Run "flutter help" to see global options.

Maybe... It does appear to fetch all the needed SDKs, but the dart.exe for Windows ends up in
bin/cache/artifacts/engine/windows-x64/dart-sdk/bin/dart.exe, but I think the flutter tool expects them in bin\cache\dart-sdk\bin\dart.exe.
Here is an example of running flutter --version on the Windows machine after running flutter precache --all-platforms on macOS:
C:\Users\paulreimer>flutter --version
'"Z:\Users\paulreimer\Development\flutter\flutter\bin\cache\dart-sdk\bin\dart.exe"' is not recognized as an internal or external command,
operable program or batch file.

Understood, I think I misunderstood your use case a bit. In this case, the snapshots and scripts in the main dart-sdk location will be incorrect, and we don't support any method of configuring that.
I would expect this to also be broken further when we switch the flutter tool to an app-jitt snapshot, which also contains platform-specific code.
I'm also not sure if gradle or xcode are correctly configured to use these directories either.

My preferred usage would be (in order):

Multiple host platforms seamlessly using the same shared flutter release directory (e.g. automatically using a platform-specific dart-sdk path)
flutter portions can be shared, but dart-sdk supports some specific argument to override like flutter --dart-sdk-path ...
A separate flutter release directory for each host platform.

So as I take it, (1) is not supported as you mention, and (2) will soon be more difficult than just overriding the dart-sdk.
I think that, the only weirdness with (3) would be that applications would not be able to share the same .packages files, as the flutter package paths would be different. So using multiple flutter checkouts this way requires the flutter --packages arg. If (3) is indeed the only way, then maybe that's where this use-case could be solved.
(my overall use-case/dream is to have all platforms {iOS, Android, macOS, Windows, Linux} running the same flutter app codebase, built from the same shared filesystem and they all hot-reload at the same time. Wouldn't that be amazing!)

For (3) Its not expected that applications can share more than source code & configuration across platforms. There are many places where we intentionally use platform specific paths, so if it works it is only by chance

I see, so the other main issue would be the build folder (which, as you say, works cross-platform in some cases only by chance). Is there a way to override the build directory? (or, alternatively, a way to do run flutter out-of-tree, and point it at a common app lib/ + config)

The build folder might not have platform-specific paths, but the .dart_tool folder definitely will.

run flutter out-of-tree

I'm not sure what you mean by this. Unless you're working in flutter/flutter you're out of tree.

For artifacts, I imagine we could drive it via a configuration file. That could be edited for a specific project, that might help for 1/2

Seems there is a .flutter_settings file which could be used per-platform to change the build dir:
https://groups.google.com/forum/#!topic/flutter-dev/VAv4DCgtSKI
I hadn't thought about .dart_tool...
As to "run flutter out-of-tree", I mean similar how you can run git from any directory (not just cwd) with e.g. git --git-dir foo/.git --work-tree foo. So in this case, something like mkdir build-win && cd build-win && flutter --project-path ..

authors: jonahwilliams paulreimer


text:
IndexedStack How to change index

I find that the index attribute of IndexedStack is final and cannot be modified. How to change the index property to switch pages

Just keep the index in state and use setstate.
import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _currentIndex = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      floatingActionButton: FloatingActionButton(
        child: Icon(Icons.refresh),
        onPressed: () {
          setState(() {
            _currentIndex = (_currentIndex + 1) % 3;
          });
        },
      ),
      body: Center(
        child: IndexedStack(
          index: _currentIndex,
          children: <Widget>[
            Container(height: 100, width: 100, color: Colors.red),
            Container(height: 100, width: 100, color: Colors.green),
            Container(height: 100, width: 100, color: Colors.blue),
          ],
        ),
      ),
    );
  }
}

Just keep the index in state and use setstate.
import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _currentIndex = 0;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      floatingActionButton: FloatingActionButton(
        child: Icon(Icons.refresh),
        onPressed: () {
          setState(() {
            _currentIndex = (_currentIndex + 1) % 3;
          });
        },
      ),
      body: Center(
        child: IndexedStack(
          index: _currentIndex,
          children: <Widget>[
            Container(height: 100, width: 100, color: Colors.red),
            Container(height: 100, width: 100, color: Colors.green),
            Container(height: 100, width: 100, color: Colors.blue),
          ],
        ),
      ),
    );
  }
}

It will show error: "Only static members can be accessed in initializers"

It will show error: "Only static members can be accessed in initializers"

Please post code which is throwing the error.

It will show error: "Only static members can be accessed in initializers"

Please post code which is throwing the error.

"Only static members can be accessed in initializers"

indicates that you reference the variable that you are trying to initialize, which is invalid in Dart.
class Foo {
  var bar = Button(Text('click me'), onPressed: () => onButtonPressed(bar)); // referencing `bar` here is invalid
}

You would need to change that to something like
class Foo {
  Foo() { // this could also be done in `initState() { ... }` if `Foo` is a `StatefulWidget`
    bar = Button(Text('click me'), onPressed: () => onButtonPressed(bar));
  }
  var bar;
}

Please consider asking support questions in one of the other channels listed at http://flutter.io/support .

authors: Kartik1607 ParryGao zoechi


text:
Include timeouts for child processes

Ocassionally, the tool spawns a program in a child process that takes a long time. We should add a parameter to the async process runners in process.dart that specifies a timeout. When a command times-out, we should send an event to analytics. A wrinkle here is that we'd also like to send an even to analytics if the flutter tool receives SIGTERM or SIGQUIT while a child process is running.

Somewhat related: https://github.com/flutter/flutter/issues/36364


text:
Listing non platform compatible plugins

Use case
When I start adding a new platform like web or desktop to my application I want to know the non-compitable plugins with the new platform
Proposal
Simply by Using a flutter command to list The Plugins which is not compatible with the targeted platform
Sample
Flutter plugin -check web
Result:
Dio 2.0.0 Android - iOS
Suggestion Dio 3.0.0 Android-iOS-Web

This command will help too much when a developer investigates to target a new platform too much otherwise he have to search plugin by plugin and debugging.

Checking would be relatively straightforward, although until the implements marker is available federated plugins would give confusing output.
Suggestions would be much trickier, and any reasonable solution would need pub APIs that don't exist yet. It's not clear how valuable that piece would be since cases where there would actually be a suggestion seem like they would be extremely rare.

@stuartmorgan Is implements already supported?
I guess this could also be helpful for this issue: #59657


text:
[video_player] Videos don't play in Safari/Chrome on iOS

video_player_web,video_player can play in Mac safari normaly by platform web, but when I play in phone safari, it doesn't work.

https://file-examples.com/wp-content/uploads/2017/04/file_example_MP4_480_1_5MG.mp4;

I  use video_player can play in Mac safari . when play in phone safari or other android phone, it doesn't work!

play in iphone

Hi @qiuguian
can you please provide your updated  flutter doctor -v
and your flutter run --verbose?
Also, to better address the issue, would be helpful
if you could post  a minimal code sample
or the steps to reproduce the problem.
Please refrain from posting pictures if not necessary.
Thank you

Thank you for respose!, you can try video_player  example,  first flutter build web, and them play in your phone broser, for iPhone safari, or other android device.
flutter:channel master v1.13.1-pre.93
device: iPhone 8 Plus
tool: Android Studio

import 'package:video_player/video_player.dart';
import 'package:flutter/material.dart';
here is  the code ,it can player in Mac safari, when in phone ,it can't!
void main() => runApp(VideoApp());
class VideoApp extends StatefulWidget {
@override
_VideoAppState createState() => _VideoAppState();
}
class _VideoAppState extends State {
VideoPlayerController _controller;
@override
void initState() {
super.initState();
controller = VideoPlayerController.network(
'http://www.sample-videos.com/video123/mp4/720/big_buck_bunny_720p_20mb.mp4')
..initialize().then(() {
// Ensure the first frame is shown after the video is initialized, even before the play button has been pressed.
setState(() {});
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Video Demo',
home: Scaffold(
body: Center(
child: _controller.value.initialized
? AspectRatio(
aspectRatio: _controller.value.aspectRatio,
child: VideoPlayer(_controller),
)
: Container(),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
setState(() {
_controller.value.isPlaying
? _controller.pause()
: _controller.play();
});
},
child: Icon(
_controller.value.isPlaying ? Icons.pause : Icons.play_arrow,
),
),
),
);
}
@override
void dispose() {
super.dispose();
_controller.dispose();
}
}

Hi @qiuguian
could you please provide your flutter run --verbose?
Please refrain from posting pictures if not necessary.
thank you

bogon:video_client_001 qiuguian$ flutter run --verbose
[  +47 ms] executing: [/Users/qiuguian/flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
[  +87 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[        ] 01953a101576a64aeaec48d434e780ce31e50538
[        ] executing: [/Users/qiuguian/flutter/] git describe --match v*.. --first-parent --long --tags
[ +131 ms] Exit code 0 from: git describe --match v*.. --first-parent --long --tags
[   +4 ms] v1.13.0-93-g01953a101
[  +18 ms] executing: [/Users/qiuguian/flutter/] git rev-parse --abbrev-ref --symbolic @{u}
[  +21 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[        ] origin/master
[        ] executing: [/Users/qiuguian/flutter/] git ls-remote --get-url origin
[  +28 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] https://github.com/flutter/flutter.git
[ +133 ms] executing: [/Users/qiuguian/flutter/] git rev-parse --abbrev-ref HEAD
[  +31 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[  +52 ms] master
[  +30 ms] executing: sw_vers -productName
[  +32 ms] Exit code 0 from: sw_vers -productName
[        ] Mac OS X
[        ] executing: sw_vers -productVersion
[  +37 ms] Exit code 0 from: sw_vers -productVersion
[        ] 10.15.1
[        ] executing: sw_vers -buildVersion
[  +29 ms] Exit code 0 from: sw_vers -buildVersion
[        ] 19B88
[  +50 ms] Artifact Instance of 'AndroidMavenArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[   +6 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[  +87 ms] executing: /Users/qiuguian/Library/Android/sdk/platform-tools/adb devices -l
[  +20 ms] Exit code 0 from: /Users/qiuguian/Library/Android/sdk/platform-tools/adb devices -l
[        ] List of devices attached
[  +25 ms] executing: /Users/qiuguian/flutter/bin/cache/artifacts/libimobiledevice/idevice_id -h
[ +131 ms] Error getting attached iOS device: ideviceinfo could not find device:
No device found with udid 04cf4709310d0462e97e2b219c89c7f73acfc4f2, is it plugged in?
. Try unlocking attached devices.
[   +4 ms] executing: /usr/bin/xcode-select --print-path
[  +10 ms] Exit code 0 from: /usr/bin/xcode-select --print-path
[        ] /Applications/Xcode.app/Contents/Developer
[   +4 ms] executing: /usr/bin/xcodebuild -version
[ +852 ms] Exit code 0 from: /usr/bin/xcodebuild -version
[        ] Xcode 11.2.1
Build version 11B500
[   +4 ms] /usr/bin/xcrun simctl list --json devices
[ +237 ms] Artifact Instance of 'AndroidMavenArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[   +6 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ +102 ms] More than one device connected; please specify a device with the '-d ' flag, or use '-d all' to act on all devices.
[ +187 ms] Chrome     • chrome     • web-javascript • Google Chrome 78.0.3904.108
[   +1 ms] Web Server • web-server • web-javascript • Flutter Tools
[  +19 ms] "flutter run" took 1,971ms.
#0      throwToolExit (package:flutter_tools/src/base/common.dart:28:3)
#1      RunCommand.validateCommand (package:flutter_tools/src/commands/run.dart:302:7)

#2      FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:601:11)

#3      FlutterCommand.run. (package:flutter_tools/src/runner/flutter_command.dart:516:33)

#4      AppContext.run. (package:flutter_tools/src/base/context.dart:146:29)
#5      _rootRun (dart:async/zone.dart:1126:13)
#6      _CustomZone.run (dart:async/zone.dart:1023:19)
#7      _runZoned (dart:async/zone.dart:1518:10)
#8      runZoned (dart:async/zone.dart:1465:12)
#9      AppContext.run (package:flutter_tools/src/base/context.dart:145:18)
#10     FlutterCommand.run (package:flutter_tools/src/runner/flutter_command.dart:506:20)
#11     CommandRunner.runCommand (package:args/command_runner.dart:197:27)
#12     FlutterCommandRunner.runCommand. (package:flutter_tools/src/runner/flutter_command_runner.dart:333:21)

#13     AppContext.run. (package:flutter_tools/src/base/context.dart:146:29)
#14     _rootRun (dart:async/zone.dart:1126:13)
#15     _CustomZone.run (dart:async/zone.dart:1023:19)
#16     _runZoned (dart:async/zone.dart:1518:10)
#17     runZoned (dart:async/zone.dart:1465:12)
#18     AppContext.run (package:flutter_tools/src/base/context.dart:145:18)
#19     FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:284:19)
#20     CommandRunner.run. (package:args/command_runner.dart:112:25)
#21     new Future.sync (dart:async/future.dart:224:31)
#22     CommandRunner.run (package:args/command_runner.dart:112:14)
#23     FlutterCommandRunner.run (package:flutter_tools/src/runner/flutter_command_runner.dart:227:18)
#24     run.. (package:flutter_tools/runner.dart:64:22)
#25     _rootRun (dart:async/zone.dart:1126:13)
#26     _CustomZone.run (dart:async/zone.dart:1023:19)
#27     _runZoned (dart:async/zone.dart:1518:10)
#28     runZoned (dart:async/zone.dart:1502:12)
#29     run. (package:flutter_tools/runner.dart:62:18)

#30     AppContext.run. (package:flutter_tools/src/base/context.dart:146:29)
#31     _rootRun (dart:async/zone.dart:1126:13)
#32     _CustomZone.run (dart:async/zone.dart:1023:19)
#33     _runZoned (dart:async/zone.dart:1518:10)
#34     runZoned (dart:async/zone.dart:1465:12)
#35     AppContext.run (package:flutter_tools/src/base/context.dart:145:18)
#36     runInContext (package:flutter_tools/src/context_runner.dart:64:24)
#37     run (package:flutter_tools/runner.dart:51:10)
#38     main (package:flutter_tools/executable.dart:65:9)
#39     main (file:///Users/qiuguian/flutter/packages/flutter_tools/bin/flutter_tools.dart:8:3)
#40     _startIsolate. (dart:isolate-patch/isolate_patch.dart:305:32)
#41     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:174:12)
bogon:video_client_001 qiuguian$

Hi @qiuguian
are those logs from video_player running on an iphone's safari, correct?
thank you

flutter build web, just the video_player can't play on phone,but  on Mac's  safari, is all correct.

I also try the futter_galley example, just like this.

the video_player can't initialize()

corrent on Mac

not corrent on phone broser

@iapicca  what is the issue going on?  can now fix it?

Have you tried loading the same video in a plain HTML page using a <video> tag without Flutter. Curious if it's a general Safari iOS problem or Flutter-specific.

@yjbanov  the same video play crrectly,   Are you  use the video_player on phone's browser?  can play crrect?

the same video play crrectly on mac's browser,  Are you use the video_player on phone's browser? can play crrect?

Any update on this? I am facing the same issue. It seems streaming mp4 fails on Safari on iOS. Something todo with the Byte-range headers

I am experiencing the same issue.
I am building a website for someone and the videos uses with video_player_web aren't displaying on Safari (iOS).
I have tried every other browser combination I can and it seems to work fine on all of them.

I'm experiencing the same issue.
video_player_web with chewie works fine on every browser combination I've tried so far apart from Safari on iOS.

I have the same issue

Me too. Does anyone know if other video formats would work?

Same issue

A work around until this issue is researched and fixed might be to use a HtmlElementView and dart:html to implement your own <video> tag the way Safari understands.

I have the same issue, and strangely, the work around effectly works.

We're also seeing what I think may be the same problem. You can test the app at https://mudeo.app, videos in the app fail to play with a media_err_src_not_supported error but the same videos play correctly in Safari and Chrome when using a video tag. You can click the 'external link' button in the bottom right corner to test the plain HTML video tag.

@rxlabz @yjbanov  Could you please provide a working example?

I created an example : https://rxlabz.github.io/vplayer_safari/#/ the video is played on desktop, but not on safari iOS with plugin. works with the htmlElementView as mentioned by @yjbanov
src : https://github.com/rxlabz/vplayer_safari cc @ImDeZz

same issue

Ran into this as well.  Also,  I couldn't load the video on iOS chrome.  Works fine on both desktop Safari /  desktop Chrome.

same issue
:(

Same issue, any instructions?

I also have this issue, any progress on this?

I'm getting same kind of problem in ext_video_player plugin...
But I debug it in iOS safari browser and found some exceptions

same issue here.

IOS Safari same issue
[✓] Flutter (Channel beta, 1.21.0-9.2.pre, on macOS 11.0 20A5364e, locale
    zh-Hans-CN)
    • Flutter version 1.21.0-9.2.pre at /Users/angus/flutter
    • Framework revision 81a45ec2e5 (3 weeks ago), 2020-08-27 14:14:33 -0700
    • Engine revision 20a9531835
    • Dart version 2.10.0 (build 2.10.0-7.3.beta)
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/angus/Library/Android/sdk
    • Platform android-R, build-tools 29.0.2
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.6)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.6, Build version 11E708
    • CocoaPods version 1.9.0.beta.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.0)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 49.0.2
    • Dart plugin version 193.7547
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6222593)

[✓] IntelliJ IDEA Ultimate Edition (version 2019.3.2)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 43.0.3
    • Dart plugin version 193.6015.53

[✓] VS Code (version 1.49.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.14.1

[✓] Connected device (3 available)
    • iPhone 8 (mobile) • 7F336652-C2C2-4320-800D-F0C53303503F • ios
      • com.apple.CoreSimulator.SimRuntime.iOS-13-6 (simulator)
    • Web Server (web)  • web-server                           • web-javascript
      • Flutter Tools
    • Chrome (web)      • chrome                               • web-javascript
      • Google Chrome 85.0.4183.102

• No issues found!

I'm experiencing the same issue.
video_player_web  works fine on every browser combination I've tried so far apart from iOS.

For me the videos don't play on Safari on PC either.  I'm using video_player: ^0.11.1+2 as video_player_web is delisted.  The videos play fine on Chrome and Opera.

Any solution for this? It's very important to support web mobile for this plugin

@rxlabz provided a workaround earlier in this thread/issue. I use in production for a hobbyist project and seems to work.
A proper fix in the plugin would still be welcome but I think a Mac is probably necessary to debug/fix the problem and I don’t have that.

I have a requirement where I need control over the video and show overlay and add music on my video. This is an issue needed to fix in safari browser. I am not able to play in iPhone safari.

I have the same problem ! dose any one find solution for this issue ?

I fix this bug by editing main.dart.js
after build web
open main.dart.js in build/web directory and in video element set q.autoplay = 1
function (a) {             var s, r = this, q = document.createElement("video")             q.src = r.b             q.autoplay = 1             q.controls = !1             s = q.style             s.border = "none"             r.d = q             q.setAttribute("playsinline", "true")             $.N5().alE("videoPlayer-" + r.c, new F.aIk(r))             q = r.d             q.toString             s = t.d7.c             W.c3(q, "canplay", new F.aIl(r), !1, s)             q = r.d             q.toString             W.c3(q, "error", new F.aIm(r), !1, s)             q = r.d             q.toString             W.c3(q, "ended", new F.aIn(r), !1, s)         },

@amirmhmdi thanks for your solution it works for me too, it is awesome thank uuu!!

Same issue here

Same issue here

Bumping. Solution doesn't work for me. Chrome on Mac works, so suspecting that it's only an issue related to Safari.

Bumping. Solution doesn't work for me. Chrome on Mac works, so suspecting that it's only an issue related to Safari.

@amirmhmdi's solution worked for me, with some additional changes below:
q.autoplay=1
q.controls=1
q.muted=1

I fix this bug by editing main.dart.js
after build web
open main.dart.js in build/web directory and in video element set q.autoplay = 1
function (a) { var s, r = this, q = document.createElement("video") q.src = r.b q.autoplay = 1 q.controls = !1 s = q.style s.border = "none" r.d = q q.setAttribute("playsinline", "true") $.N5().alE("videoPlayer-" + r.c, new F.aIk(r)) q = r.d q.toString s = t.d7.c W.c3(q, "canplay", new F.aIl(r), !1, s) q = r.d q.toString W.c3(q, "error", new F.aIm(r), !1, s) q = r.d q.toString W.c3(q, "ended", new F.aIn(r), !1, s) },

Thanks, that solved my problem.
Is there anyway to tell the developers to fix it, so we don't have to edit the built files every time?

Thanks, that solved my problem.
Is there anyway to tell the developers to fix it, so we don't have to edit the built files every time?

Give OP a thumb up to give this issue higher attention from devs.

Still having this problem

I can reproduce it using the official example

flutter doctor -v
[✓] Flutter (Channel master, 2.1.0-13.0.pre.322, on macOS 11.2.3 20D91
    darwin-x64, locale en-GB)
    • Flutter version 2.1.0-13.0.pre.322 at
      /Users/tahatesser/Code/flutter_master
    • Framework revision e93590474d (4 hours ago), 2021-03-30 02:14:03 -0400
    • Engine revision dbcbf69a57
    • Dart version 2.13.0 (build 2.13.0-175.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
    • Android SDK at /Volumes/Extreme/SDK
    • Platform android-30, build-tools 30.0.3
    • ANDROID_HOME = /Volumes/Extreme/SDK
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Volumes/Extreme/Xcode.app/Contents/Developer
    • Xcode 12.4, Build version 12D4e
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /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
      1.8.0_242-release-1644-b3-6915495)

[✓] VS Code (version 1.54.3)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.20.0

[✓] Connected device (3 available)
    • sdk gphone x86 (mobile) • emulator-5554 • android-x86    • Android 11 (API
      30) (emulator)
    • macOS (desktop)         • macos         • darwin-x64     • macOS 11.2.3
      20D91 darwin-x64
    • Chrome (web)            • chrome        • web-javascript • Google Chrome
      89.0.4389.90

• No issues found!

Another workaround if you don't want to touch the built main.dart.js.

Download the video_player_web project from https://github.com/flutter/plugins/tree/master/packages/video_player/video_player_web
Locate initialize in video_player_web.dart and update those "autoplay" values to true.
Adds to the pubspec.yaml:

dependency_overrides:
  video_player_web:
    path: ./video_player_web

Still having the issue. Unfortunately @amirmhmdi 's fix does not work for me.

Same. The solution doesn't work for me either. Does anyone have other packages that work?

Still having the issue. Unfortunately @amirmhmdi 's fix does not work for me.

After much trial and error, renaming the video somehow solved it.
My videos on Firebase did not end with .mp4, but still worked perfectly on android and pc.
Renaming the video to end with .mp4 combined with Amir's fix did it for me.

Hi, we are having problems getting this to work for flutter web. The player never initializes and just hangs. None of the web solutions mentioned here work with the current version of flutter.

Hello all! I'm sorry I haven't commented here before (I thought I had!). This issue has grown for a while, and from what I've read, I think we're actually having several issues here.
I'm going to try and explain the issues I think we have, and maybe steps to verify each of them.

The video file is not compatible with the browser. Not all browsers are able to open the same video formats. This is documented in the README.
The video will not autostart. Autostart/autoplay is severely limited in browsers. As a very simplified heuristic, only videos without sound (or that are muted) are allowed to auto-start without user interaction.

How to know what's affecting me?
Test your use case in a raw HTML page:

You can create a very simple HTML page with a video tag that attempts to open your video. See examples. If your video plays back in an HTML page, it should play in Flutter Web (the web version of the plugin is using a standard video tag). If your video doesn't play in a specific browser, it might need to be re-encoded for that browser. This normally cannot be done client-side, and you might need to have several versions of the same video for it to work across all browsers.
Try to start your video muted (.setVolume(0)) before calling play. Normally there's no need to add the autoplay attribute by hand; calling play as soon as the controller is ready, should be the same as having autoplay. You can also use the suggestion in "1" to create a raw HTML page with an auto-playing video tag, and see if it works there or not.

If after testing the above, you're finding it's a different issue, please, do create a separate issue for it, so it doesn't get mixed up/lost within the comments of this one!
How to report more info
The amount of video formats and browser combinations can be enormous. Ideally, when reporting a +1, please add:

What is the OS and Browser where the issue is happening? (Try to be as specific as possible with the version info.)
What have you tried? Can you include some samples from your testing?

Super helpful: can you include the video (or a part of it) that is giving you trouble?
A small Flutter Web repro case with code similar to what your page needs to do (are you opening a video after a click? immediately after navigating to a new tab?)
(Maybe show us the HTML test page you built in the step above too where the issue reproduces?)

Are there any errors in the Chrome DevTools?

Check the JS Console, and the Network panels.

Thanks for reading the wall of text above! Let's get the video player working great on the web!

flutter web项目 [video_player]视频无法在iOS浏览器中打开播放

Excellent report, thanks @Leffe108!

Hi,
I had the same issue and needed the video functionality for a current project. So I added the following line in the video_player_web-2.0.0/lib/video_player_web.dart package (line 182):
// Allows Safari iOS to play the video inline
videoElement.setAttribute('playsinline', 'true');
videoElement.setAttribute('autoplay', 'false'); // <-- Added this line. Safari seems to need this tag although it's false

Works good with the latest Safari on IPhone. Maybe it would good to influence such attributes from outside...

I opened https://github.com/flutter/plugins/pull/3985 to disable autoplay as described above

@abyesilyurt
I change main.dart.js like you but the problem not solved. (in Html & canvas kit release)

I opened flutter/plugins#3985 to disable autoplay as described above

This has been merged and published: https://pub.dev/packages/video_player_web/changelog#201

Is there a way to test this?
I tried to add video_player_web: ^2.0.1 as a dependency and re-build my demo but it doesn't fix the problem. When I inspect the video tag on a desktop browser (firefox) in windows the video tag does not get autoplay set to false. I don't know however if it is supposed to do that on desktop browsers too or only iPhone|iPod|iPad|MacIntel?

@Leffe108 try deleting your pubspec.lock to ensure that you're getting the latest version of video_player_web (or check inside pubspec.lock what version of video_player_web you're pub-getting).
From the code that @felangel wrote, it should be adding autoplay=false unconditionally. Here.

@ditman My test case now works using video_player_web 2.0.1.
I accidentally deployed ./web instead of ./build/web and forgot to update base url so it still used the old code. 🤦♀

That's great news @Leffe108! Let's see if others in the thread experience an improvement! (I hope all who were adding autoplay=false to the compiled JS directly would see the improvement as well!)

Hi, even after using video_player_web: ^2.0.1 video don't play in Safari/Chrome on iOS. Is anyone here still experiencing this?

@osho-chawla please, take a look at this: https://github.com/flutter/flutter/issues/47030#issuecomment-841419012

My Problem is little different,
What I did : I have implemented video_player in flutter web for background in stack.
Problem : Video Player is not playing video after load.
Browser am using : Chrome
Extras : Video is working fine and all but I have reload my page inside my website(not chrome button).
Wht should I do now?
Website Link : https://sameer-ahmed-portfolio.web.app/

My Problem is little different,
What I did : I have implemented video_player in flutter web for background in stack.
Problem : Video Player is not playing video after load.
Browser am using : Chrome
Extras : Video is working fine and all but I have reload my page inside my website(not chrome button).
Wht should I do now?
Website Link : https://sameer-ahmed-portfolio.web.app/

I would bet that the video plays without user interaction and therefore gets blocked by chrome which I IIRC is stated in dev console when it happens. I had that issue when I implemented a share quiz function that deep link straight into a question. I solved it with an extra UI dialog informing user they got challenged and ask if they accept with yes/no button obtaining user interaction prior to playing video.

Thanks @Leffe108,
Now, I am thinking to implement a welcome screen before which will forward to first screen and try to get a call from there :)

Following is my sample code for safari/ios, I have turned autoplay off and volume to 0 because safari does not support autoplay  of unmuted video
flick_video_player can play in Mac safari normally by platform web, but when I play in phone safari, it doesn't work
### only audio can be heard but there is no video visible.
flickManager = FlickManager(
          videoPlayerController: VideoPlayerController.network(
              "https://flutter.github.io/assets-for-api-docs/assets/videos/bee.mp4")
          autoPlay: false);
      flickManager?.flickControlManager?.mute();
      flickManager?.flickControlManager?.setVolume(0);

an issue regarding the video_player_web was resolved here but the problem still persists in the flick video player.

@sxmeer-ahmed I had the same problem. Auto play is restricted by browsers.
One option as stated is to make a dialog for user interaction.
Other option is to start video on mute, and let users know their video is on mute. So just before videoController.play(), set the volume to 0. I think this way is more elegant than other one.

May I ask, do you have the final solution? I also encountered this problem, very anxious

In case it digs someone out of a hole while the main issue is being resolved, this is working well for me.
`import 'dart:html';
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
///Working well in Windows, Linux, MacOS, iOS and Android Mobile Web / PWA
class WebVideoElement extends StatefulWidget {
const WebVideoElement(this.src);
final String src;
final double startAt = 0;
final bool autoplay = false;
final bool controls = true;
@override
_WebVideoElementState createState() => _WebVideoElementState();
}
class _WebVideoElementState extends State {
@override
void initState() {
super.initState();
String? URL = 'http://www.website.com/pathtovideo' + '#t=${widget.startAt}';
// Do not remove the below comment - Fix for missing ui.platformViewRegistry in dart.ui
// ignore: undefined_prefixed_name
ui.platformViewRegistry.registerViewFactory(widget.src, (int viewId) {
//https: //api.flutter.dev/flutter/dart-html/VideoElement-class.html
final video = VideoElement()
..src = URL
..autoplay = widget.autoplay
..controls = widget.controls
..style.border = 'none'
..style.borderColor = 'red'
..style.height = '100%'
..style.width = '100%';
// Allows Safari iOS to play the video inline
video.setAttribute('playsinline', 'true');
return video;
});
}
@override
Widget build(BuildContext context) {
return HtmlElementView(viewType: widget.src);
}
}`

@zambetpentru There was a fix implemented in video_player_web 2.0.1 which solved the problem for some. To use it add video_player_web: ^2.0.1 to your pubspec.yaml and rebuild and re-deploy.
If this does not solve the problem in your app with your video source, then please take a look at this: https://github.com/flutter/flutter/issues/47030#issuecomment-841419012 on how to report the specifics of your case.

on flutter 2.5.1 video player 2.2.4
video play on android iOS and chrome and safari Mac  ,but safari iOS doesn't play.

Autoplay is not working for me on Safari Mac  Version 15.4
So I wonder is this the right implementation for auto-play

  child: FutureBuilder(
    future: Future.wait([
      _initializeVideoFuture,
      _videoController.setVolume(0),
      _videoController.setLooping(true),
      _videoController.play(),
    ]),

import 'package:flutter/material.dart';
import 'package:frontend_framework/frontend_framework.dart';

class AnimatedAsset extends StatefulWidget {
  const AnimatedAsset({
    Key key,
    @required this.asset,
    this.alternativeImage = '',
    @required this.packageName,
    @required this.width,
    @required this.height,
  }) : super(key: key);

  final String asset, alternativeImage, packageName;
  final double width, height;

  @override
  State<AnimatedAsset> createState() => _AnimatedAssetState();
}

class _AnimatedAssetState extends State<AnimatedAsset> {
  VideoPlayerController _videoController;
  ChewieController _chewieController;
  Future<void> _initializeVideoFuture;

  @override
  void initState() {
    super.initState();
    _videoController = VideoPlayerController.asset(
      widget.asset,
      package: widget.packageName,
    );

    _initializeVideoFuture = _videoController.initialize().then(
      (value) async {
        // muted videos can autoplay on chrome
      },
    );
  }

  @override
  void dispose() {
    _videoController.dispose();
    _chewieController.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    //video has no auto-play feature on Safari so I shows animated image
    //and macOS has no support for video player yet
    final useAlternativeImage =
        (UniversalPlatform.isDesktop || BrowserDetector().isSafari) &&
            widget.alternativeImage.isNotEmpty;

    if (useAlternativeImage) {
      return Image.asset(
        widget.alternativeImage,
        width: widget.width,
        height: widget.height,
        package: widget.packageName,
        fit: BoxFit.contain,
      );
    }

    return SizedBox(
      width: widget.width,
      height: widget.height,
      child: FutureBuilder(
        future: Future.wait([
          _initializeVideoFuture,
          _videoController.setVolume(0),
          _videoController.setLooping(true),
          _videoController.play(),
        ]),
        builder: (context, snapshot) {
          if (snapshot.connectionState == ConnectionState.done) {
            _chewieController = ChewieController(
              videoPlayerController: _videoController,
              autoPlay: true,
              looping: true,
              showControls: false,
              showControlsOnInitialize: true,
              showOptions: false,
              allowMuting: true,
              autoInitialize: true,
            );

            return Chewie(
              controller: _chewieController,
            );
          }
          return const PyrinasLoadingIndicator();
        },
      ),
    );
  }
}

@a-eniou-pvotal:
Are you trying to auto-play before the user has tapped/interacted with your web-app or after user interaction? I know chrome and likely also safari will block auto-play if you try to play a video before user has interacted with a website/web app. I solved this in my quiz app when receiving a share link to on web show a prompt dialog that asks the user if they want to accept the challenge they received or not. If they accept it, I then auto-play first question video and it works on web.
If your video has audio, try to auto-play muted (after user interaction) to see if that helps.

@Leffe108 so why this sample works fine on safari but not Flutter even I used same HTML content but it didn't work on safari
https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_video_autoplay

@zambetpentru my issue with auto-play, and I tried your snippet but still no auto-play on Safari mac

@zambetpentru my issue with auto-play, and I tried your snippet but still no auto-play on Safari mac

Notice that this issue so far has been about problems with playback in safari on iOS - not safari on mac. Furthermore many people report that it works fine in Safari on mac.

Nope, I have a problem even on safari on Mac (in flutter web).
When I compiling application to iOS player is working.

Seems the player is downloading MP4 by pieces. And the link to MP4 is opening normally without video player. Seems to be a bug in flutter video_player plugin.

Web console in Safari on Mac.

Hello guys, any solution for this? I rendered my project with html mode and it is playing properly on Chrome but not on Safari

Hello guys, any solution for this? I rendered my project with html mode and it is playing properly on Chrome but not on Safari

Hi, did you try my code above? It's still working consistently for me.

@zambetpentru i need to use video_player plugin,  it is working well on Chrome but not on Safari.... Strange, before it was working properly...

There has been a recent fix with clipped platform views in safari that might have fixed some of the remaining cases on this issue.
If your video player was inside any form of clip-path (like a RRect), Safari wouldn't paint it before this landed:

https://github.com/flutter/engine/pull/35948

(Just letting buddies on this venerable issue know!)

https://github.com/flutter/engine/pull/35948
Waiting for this to land in Stable version.

@ditman We face this issue on Safari web in CanvasKit still. Is it not on Stable yet? When can we expect it to land? Thanks for all your efforts.

https://github.com/flutter/engine/pull/35948
This fix is landed in Stable 3.3.10.
Still the ClipRRect is not showing the full content on Safari.
I'm using the ClipRRect around the Html Video Element. And the player is not showing the full video content using the ClipRRect.

im use Canvaskit, sometimes video player fail load video from url in safari browser on ios simulator, but its always worked on google chrome, and rare fail in mac os

kind of sad that this issue is still not fixed. maybe exposing video attributes could help to apply the needed settings.
https://stackoverflow.com/a/72658854/5525799

bump

Using media_kit seems to work
https://pub.dev/packages/media_kit

@TahaTesser almost 4 years and we don't have such a basic thing like playing videos everywhere on Flutter Web? Seriously?

@TahaTesser @yjbanov
Almost 4 years and we don't have such a basic thing like playing videos everywhere on Flutter Web? Seriously?

@yjbanov @TahaTesser @ditman
It's quite disappointing to see such basic thing as videos still not working in Flutter Web 😕

Even running official example from https://pub.dev/packages/video_player#example on Safari doesn't work. The video is just not showing.
Env:

flutter: 3.13.7
video_player 2.7.2
iOS 16.7.1

I've published a fix for the issue that @PawlikMichal25 reported:

https://github.com/flutter/flutter/issues/137023

In video_player_web: ^2.1.2 (which should be automatically be picked up by your apps as you upgrade your dependencies).
Here's a sample app: https://dit-videoplayer-tests.web.app (may not work if I've repurposed the domain for anything!)

I am facing a similar issue with video_player: 2.8.2 on Edge browser Android 14.
In the case of iOS using the latest flutter version (3.13.9 -> 3.16.8) worked for me.

authors: Abdelrahman-Sousa AngusPei HiroshiHorie ImDeZz Leffe108 NemanjaLugi PawlikMichal25 SebastianKumor TahaTesser Toolenaar WD-J WSDDi a-eniou-pvotal abyesilyurt amirmhmdi amorenew aytunch bortka carman247 chntu dannycortesv deepak786 deepikadt dev-weenit ditman faslurrajah felangel ferozstk git9am hillelcoren iapicca ikarelin imabhishekkumar kasyrm kira2015 m-j-g mahanabd martin-matj mrinaljain okiabrian123 osho-chawla phide qiuguian razfazz rpk98c rxlabz sohail-bakhtiari sxmeer-ahmed tsdevelopment yaizudamashii yjbanov zacherygentry zambetpentru zeevgrim


text:
flutter 1.12.13+5 app is getting crashed in samsung tab E os 4.4.4

[ERROR:flutter/shell/platform/android/platform_view_android_jni.cc(39)] java.lang.SecurityException: uid 10116 does not have android.permission.UPDATE_DEVICE_STATS.
E/flutter (30658): 	at android.os.Parcel.readException(Parcel.java:1472)
E/flutter (30658): 	at android.os.Parcel.readException(Parcel.java:1426)
E/flutter (30658): 	at android.app.ActivityManagerProxy.reportActivityFullyDrawn(ActivityManagerNative.java:5196)
E/flutter (30658): 	at android.app.Activity.reportFullyDrawn(Activity.java:1548)
E/flutter (30658): 	at io.flutter.embedding.android.FlutterActivity.onFlutterUiDisplayed(FlutterActivity.java:942)
E/flutter (30658): 	at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate$1.onFlutterUiDisplayed(FlutterActivityAndFragmentDelegate.java:90)
E/flutter (30658): 	at io.flutter.embedding.android.FlutterView$2.onFlutterUiDisplayed(FlutterView.java:119)
E/flutter (30658): 	at io.flutter.embedding.engine.FlutterJNI.onFirstFrame(FlutterJNI.java:262)
E/flutter (30658): 	at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter (30658): 	at android.os.MessageQueue.next(MessageQueue.java:138)
E/flutter (30658): 	at android.os.Looper.loop(Looper.java:123)
E/flutter (30658): 	at android.app.ActivityThread.main(ActivityThread.java:5590)
E/flutter (30658): 	at java.lang.reflect.Method.invokeNative(Native Method)
E/flutter (30658): 	at java.lang.reflect.Method.invoke(Method.java:515)
E/flutter (30658): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1268)
E/flutter (30658): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
E/flutter (30658): 	at dalvik.system.NativeStart.main(Native Method)
E/flutter (30658):
F/flutter (30658): [FATAL:flutter/shell/platform/android/platform_view_android_jni.cc(111)] Check failed: CheckException(env).

I created a new project and the app is not opening not getting why?

Hi @Virendra-Varma
given the error in your logs check please your android-manifest file for required permission
the issue might be related to your app's code rather than flutter itself;
if you believe that the framework isn't behaving as intended
please provide a minimal code sample or the steps to reproduce the issue.
If you are looking for assistance on personal code,
please see https://flutter.dev/community for resources and
you may also get some help if you post it on Stack Overflow.
thank you

Hi @BondarenkoStas Thanks for reply
but I think You didn't read the last line of my post
I created a new project and the app is getting crashed immediately after opening and while installing the app in tab it's show the warning and after crash just show
F/flutter (30658): [FATAL:flutter/shell/platform/android/platform_view_android_jni.cc(111)] Check failed: CheckException(env).
that's the reason i am not getting why it's not working
please correct me if anywhere I am wrong.

Hi @Virendra-Varma
can you please provide your updated  flutter doctor -v
and your flutter run --verbose?
Also, to better address the issue, would be helpful
if you could post  a minimal code sample
or the steps to reproduce the problem.
Thank you

here is my main.dart file code
`import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
    title: Text(widget.title),
  ),
  body: Center(

    child: Column(
      mainAxisAlignment: MainAxisAlignment.center,
      children: <Widget>[
        Text(
          'You have pushed the button this many times:',
        ),
        Text(
          '$_counter',
          style: Theme.of(context).textTheme.display1,
        ),
      ],
    ),
  ),
  floatingActionButton: FloatingActionButton(
    onPressed: _incrementCounter,
    tooltip: 'Increment',
    child: Icon(Icons.add),
  ), // This trailing comma makes auto-formatting nicer for build methods.
);

}
}
`

my flutter doctor -v
`D:\sample\flutter\chart\flutter_chart3_app>flutter doctor -v
[√] Flutter (Channel stable, v1.12.13+hotfix.5, on Microsoft Windows [Version 6.1.7601], locale en-US)
• Flutter version 1.12.13+hotfix.5 at D:\flutter
• Framework revision 27321ebbad (8 days ago), 2019-12-10 18:15:01 -0800
• Engine revision 2994f7e1e6
• Dart version 2.7.0
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at D:\AndroidStudioSDK
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.2
• Java binary at: D:\android-studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
• All Android licenses accepted.
[√] Android Studio (version 3.5)
• Android Studio at D:\android-studio
• Flutter plugin version 42.1.1
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
[√] Connected device (1 available)
• SM T561 • 10.10.50.34:5555 • android-arm • Android 4.4.4 (API 19)
• No issues found!
`

Thank you for providing this info @Virendra-Varma

@iapicca  sorry for late response here is my flutter run --verbs

I have what appears to be a similar problem on an Android 4.4.4 Huawei G620S device (I keep it around for testing apps against 4.4).  I'll try to attach it to the debugger and update.

having the same problem. Any solutions?

This is a dupe of https://github.com/flutter/flutter/issues/46172 and should be fixed on master now.

authors: BondarenkoStas PhilGPk RadianEleven Virendra-Varma iapicca xster


text:
Old print statements printed in console before app is built and launched

Upon clicking debug app button (in vscode)
The output is as follows
Launching lib/main.dart on ONEPLUS A3003 in debug mode...
I/flutter (29232): clickSend
I/flutter (29232): clickSend
I/flutter (29232): pushtoNav
I/flutter (29232): clickSend
I/flutter (29232): pushtoNav
✓ Built build/app/outputs/apk/debug/app-debug.apk.

These unusual print statements were printed by a function using print()  in a debug session before.
Although they aren't causing any failure or error, these shouldn't be there

flutter doctor
[✓] Flutter (Channel beta, v1.12.13+hotfix.6, on Linux, locale en_US.UTF-8)
    • Flutter version 1.12.13+hotfix.6 at /home/pkmn/Softwares/flutter
    • Framework revision 18cd7a3601 (7 days ago), 2019-12-11 06:35:39 -0800
    • Engine revision 2994f7e1e6
    • Dart version 2.7.0

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /home/pkmn/Android/Sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 28.0.3
    • Java binary at: /home/pkmn/Softwares/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b16-5323222)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Android Studio (version 3.4)
    • Android Studio at /home/pkmn/Softwares/android-studio
    • Flutter plugin version 39.0.1
    • Dart plugin version 183.6270
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b16-5323222)

[✓] VS Code (version 1.39.2)
    • VS Code at /usr/share/code
    • Flutter extension version 3.7.1

[✓] Connected device (3 available)
    • ONEPLUS A3003 • b0aec25d   • android-arm64  • Android 9 (API 28)
    • Chrome        • chrome     • web-javascript • Google Chrome 79.0.3945.88
    • Web Server    • web-server • web-javascript • Flutter Tools

• No issues found!

Hi @mannprerak2
could you post  a minimal code sample
or the steps to reproduce the problem.
Thank you

STEPS TO REPRODUCE
Create a blank app.. with just one button and printed some strings in its onPressed() method
main.dart file
import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: 'Flutter Demo',
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        home: Scaffold(
          body: Center(
            child: RaisedButton(
              child: Text("Click"),
              onPressed: () {
                print("abc");
                print("123");
              },
            ),
          ),
        ));
  }
}

START DEBUGGING
I clicked the button twice and the stopped debugging
Here's the output initially
Launching lib/main.dart on ONEPLUS A3003 in debug mode...
✓ Built build/app/outputs/apk/debug/app-debug.apk.
I/flutter (17200): abc
I/flutter (17200): 123
I/flutter (17200): abc
I/flutter (17200): 123
Application finished.
Exited (sigterm)

START DEBUGGING AGAIN
Click on Start Debug again.
I automatically get this in my debug console without me doing anything at all
Launching lib/main.dart on ONEPLUS A3003 in debug mode...
I/flutter (17200): abc
I/flutter (17200): 123
I/flutter (17200): abc
I/flutter (17200): 123
✓ Built build/app/outputs/apk/debug/app-debug.apk.

Note that the print statements are before the apk was even built

I see the same on windows

Thanks for the sample @mannprerak2

Same issue

Same using Android Studio

It sounds like the run and attach cases need to use different log readers.

Same problem for me.

@blasten Is this a duplicate of https://github.com/flutter/flutter/issues/47629?  This one is assigned to you: would you rather keep this one or that one?

Yes, this is duplicate. This issue is fixed on master.

Hi @mannprerak2
I see there's an open issue addressing the case you described.
Please follow up on that issue,
I'm closing the current one as duplicate.
If you disagree please write in the comments
and I will reopen it.
Thank you

authors: BondarenkoStas SivaCorp blasten furkanvatandas iapicca jmagman jonsamwell mannprerak2 msal4 zanderso


text:
How to keep the state of searchdelegate

I am having a problem with SearchDelegate that when i navigate away and when i pop back to search, the search results start rebuilding agains.

Hi @IRFAN-GujjAR
This platform is not meant for assistance on personal code.
Please see https://flutter.dev/community for resources for asking questions like this,
you may also get some help if you post it on Stack Overflow.
Closing, as this isn't an issue with Flutter itself,
if you disagree please write in the comments and I will reopen it
Thank you

authors: IRFAN-GujjAR iapicca


text:
Gallery, Buttons: Dropdown has lots of white padding at top

On my iPod Touch. I opened Gallery, then tapped Buttons, then tapped Dropdown.
See below, notice how there is a lot of white padding at the top of the dropdown display.
Also, looks like we're not showing the full intended list?

Ah, this is scrollable. Once I scroll the list contents, the issue corrects itself. The above screenshot is the initial display.

I can't repro this anymore. Looks like something fixed it.

authors: mpcomplete sethladd