Repository: flutter
Issue: [Web][Firefox][Android] Cannot open file picker sometimes
Labels: framework,platform-web,has reproducible steps,browser: firefox,P2,found in release: 2.8,found in release: 2.9,team-web,triaged-web

There is problem to open file picker in Mozilla Firefox on Android (google chrome and firefox on ios work well)
Problem is reproduced when I use [file_picker](https://pub.dev/packages/file_picker) plugin or when I use only native web tools from `dart:html`

## Steps to Reproduce

<!-- Please include full steps to reproduce so that we can reproduce the problem. -->

1. Execute `flutter build web` on the code sample and run web server
2. Open app in firefox on android device
3. Click on plus button

**Expected results:** File picking dialog shows up

**Actual results:** Sometimes nothing happens and there is warning in console:
`<input> picker was blocked due to lack of user activation.`

<details>
<summary>Code sample</summary>

<!--
      Please create a minimal reproducible sample that shows the problem
      and attach it below between the lines with the backticks.

      To create it you can use `flutter create bug` command and update the `main.dart` file.

      Alternatively, you can use https://dartpad.dev/
      which is capable of creating and running small Flutter apps.

      Without this we will unlikely be able to progress on the issue, and because of that
      we regretfully will have to close it.
-->

web/index.html
```html
...
<body>
  <input type="file" name="picker" id="file_picker">
  ...
</body>
```

main.dart
```dart
import 'dart:html';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);

  final String title;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(title),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          final inputElement = document.querySelector('#file_picker');
          inputElement?.click();
        },
        tooltip: 'Pick',
        child: const Icon(Icons.add),
      ),
    );
  }
}

```

</details>

<details>
  <summary>Logs</summary>

I build app with `flutter build web` and then serve `build/web` directory with simple static web server to run app on my android phone and then debug it with `about:debugging` page in firefox on desktop.
When bug is reproduced I have this warning in firefox console:
```
<input> picker was blocked due to lack of user activation.
```

<!--
     Run `flutter analyze` and attach any output of that command below.
     If there are any analysis errors, try resolving them before filing this issue.
-->
`flutter analyze`
```
Analyzing firefox_file...

   info - Avoid using web-only libraries outside Flutter web plugin packages - lib\main.dart:1:1 -
          avoid_web_libraries_in_flutter
```

<!-- Finally, paste the output of running `flutter doctor -v` here. -->

```
$ flutter doctor -v
[✓] Flutter (Channel stable, 2.8.0, on Microsoft Windows [Version 10.0.22000.348], locale ru-RU)
    • Flutter version 2.8.0 at C:\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision cf44000065 (6 days ago), 2021-12-08 14:06:50 -0800
    • Engine revision 40a99c5951
    • Dart version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
    • Android SDK at C:\Users\limon\AppData\Local\Android\sdk
    • Platform android-32, build-tools 32.0.0
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at C:\Users\limon\AppData\Local\Google\Chrome\Application\chrome.exe

[!] Visual Studio - develop for Windows (Visual Studio Build Tools 2019 16.11.7)
    • Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools
    • Visual Studio Build Tools 2019 version 16.11.31911.196
    ✗ The current Visual Studio installation is incomplete. Please reinstall Visual Studio.

[✓] Android Studio (version 2020.3)
    • Android Studio at C:\Program Files\Android\Android Studio
    • 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.10+0-b96-7249189)

[✓] VS Code, 64-bit edition (version 1.63.0)
    • VS Code at C:\Program Files\Microsoft VS Code
    • Flutter extension version 3.29.0

[✓] Connected device (5 available)
    • SM A505FM (mobile)               • R58M310EWYE   • android-arm64  • Android 11 (API 30)
    • sdk gphone x86 64 arm64 (mobile) • emulator-5554 • android-x64    • Android 11 (API 30) (emulator)
    • Windows (desktop)                • windows       • windows-x64    • Microsoft Windows [Version 10.0.22000.348]
    • Chrome (web)                     • chrome        • web-javascript • Google Chrome 96.0.4664.93
    • Edge (web)                       • edge          • web-javascript • Microsoft Edge 96.0.1054.43

! Doctor found issues in 1 category.
```

</details>

Android Mozilla Firefox version
```
95.1.0 (Build #2015848803)
AC: 95.0.13, 58539f17f6
GV:95.0-20211129150630
AS: 86.0.1
```