Flutter webview package inline media problem - flutter

webview_flutter 1.0.7 using your package.
https://github.com/flutter/plugins/pull/3334/commits/1d7e5ebab3c86bf5f2bf252ae14bca87be33c414
I made the changes on the page. Although I made all the changes, the ipad is working in full screen but the iphone does not work
sample videos as below
https://user-images.githubusercontent.com/57063848/104122686-8abf8700-5357-11eb-96b4-beb18cc5c4e1.mov
https://user-images.githubusercontent.com/57063848/104122691-901cd180-5357-11eb-9dcc-aa6b842263de.mov
sample code
import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Welcome to Flutter',
home: Scaffold(
body: WebView(
initialUrl: "https://www.medivizyon.com.tr/in5",
javascriptMode: JavascriptMode.unrestricted,
initialMediaPlaybackPolicy: AutoMediaPlaybackPolicy.always_allow,
allowsInlineMediaPlayback: true,
),
),
);
}
flutter doctor -v
[✓] Flutter (Channel stable, 1.22.5, on Mac OS X 10.15.7 19H2 darwin-x64, locale tr-TR)
• Flutter version 1.22.5 at /Users/gokhan/flutter
• Framework revision 7891006299 (4 weeks ago), 2020-12-10 11:54:40 -0800
• Engine revision ae90085a84
• Dart version 2.10.4
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at /Users/gokhan/Library/Android/sdk
• Platform android-29, build-tools 29.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_242-release-1644-b3-6222593)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 12.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.3, Build version 12C33
• CocoaPods version 1.10.0
[✓] Android Studio (version 4.0)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 46.0.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
[✓] VS Code (version 1.52.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.18.1
pubspec.yaml
version: 1.0.0+1
environment:
sdk: ">=2.8.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.0
webview_flutter: ^1.0.7
dev_dependencies:
flutter_test:
sdk: flutter
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true

pythoneer commented yesterday
What is the current state of this issue? Flutter 2 is stable and released and the same is true for webview_flutter in version 2.0.2 . I can see changes being made to allow this
} else if ([key isEqualToString:#"allowsInlineMediaPlayback"]) {
NSNumber* allowsInlineMediaPlayback = settings[key];
_webView.configuration.allowsInlineMediaPlayback = [allowsInlineMediaPlayback boolValue];
} else {
But i don't have the desired effect. It is still not working as described in this issue. If i fork this and apply the changes manually
WKWebViewConfiguration* configuration = [[WKWebViewConfiguration alloc] init];
configuration.userContentController = userContentController;
[self updateAutoMediaPlaybackPolicy:args[#"autoMediaPlaybackPolicy"]
inConfiguration:configuration];
configuration.allowsInlineMediaPlayback = true;
it is working as expected.

Related

Flutter Internationalization, intl code generation not working

I created a new Flutter project with Android Studio. I'm using null-safety and I'm running the application on a physical device yet the code-generation is not working, there is no flutter_gen folder inside .dart_tool folder just flutter_build folder.
I followed the steps in Flutter's official Internationalizing documentation
Im not using Flutter Intl plugin because it doesn't support null-safety (I'm aware you can make an script to add an old dart version at the top of each generated file as a workaround)
flutter doctor command output:
[✓] Flutter (Channel beta, 1.26.0-17.5.pre, on Microsoft Windows [Versión 10.0.19042.804], locale es-ES)
• Flutter version 1.26.0-17.5.pre at <PATH>
• Framework revision 1fe38dcb5f (3 days ago), 2021-02-10 16:25:47 -0800
• Engine revision d4453f6018
• Dart version 2.12.0 (build 2.12.0-259.9.beta)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at <PATH>
• Platform android-30, build-tools 30.0.2
• Java binary at: <PATH>
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.
[✓] Android Studio (version 4.1.0)
• Android Studio at <PATH>
• 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-b01)
[✓] VS Code (version 1.53.2)
• VS Code at <PATH>
• Flutter extension version 3.19.0
[✓] Connected device (1 available)
• <DEVICE> • android-arm • Android 8.1.0 (API 27)
• No issues found!
/pubscpec.yaml:
name: example_app
description: A new Flutter application.
publish_to: 'none'
version: 1.0.0+1
environment:
sdk: ">=2.12.0-0 <3.0.0"
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
intl: ^0.17.0-nullsafety.2
cupertino_icons: ^1.0.1
dev_dependencies:
flutter_test:
sdk: flutter
integration_test:
sdk: flutter
flutter:
uses-material-design: true
generate: true
/lib/main.dart:
import 'package:example_app/ui/screen/home_page.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
// TODO: uncomment the line below after codegen
// import 'package:flutter_gen/gen_l10n/app_localizations.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage('Flutter Demo Home Page'),
localizationsDelegates: [
// ... app-specific localization delegate[s] here
// TODO: uncomment the line below after codegen
// AppLocalizations.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: [
const Locale('en', ''), // English, no country code
const Locale('es', ''), // Spanish, no country code
],
);
}
}
/lib/l10n.yaml:
arb-dir: lib/l10n
template-arb-file: app_en.arb
output-localization-file: app_localizations.dart
lib/l10n/app_en.arb
{
"helloWorld": "Hello World!"
}
lib/l10n/app_es.arb
{
"helloWorld": "Hola mundo!"
}
It was my mistake, moving /lib/l10n.yaml/ to /l10n.yaml/ solves the problem.
Answered by perqin.

Flutter auto_route_generator not building, FormatException: Not an instance of List

I'm trying to run Flutter pub run build_runner build,
to generate a router.g.dart file for navigation.
I've run a build_runner clean, a whole project clean then build but no luck.
Im following a tutorial, he just seems to run it exactly with the code I have and its fine. No one else in the comments seem to have this issue and I can't find anything about it online.
It fails saying:
[SEVERE] auto_route_generator:autoRouteGenerator on lib/app/router.dart:
FormatException: Not an instance of List.
[INFO] Running build completed, took 16.2s
[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 48ms
[SEVERE] Failed after 16.3s
pub finished with exit code 1
My router.dart code:
import 'package:auto_route/auto_route_annotations.dart';
import 'package:stacktest/ui/views/covers/cover_view.dart';
import 'package:stacktest/ui/views/home/home_view.dart';
import 'package:stacktest/ui/views/startup/startup_view.dart';
#MaterialAutoRouter()
class $Router {
#initial
StartupView startupViewRoute;
HomeView homeViewRoute;
CoverView coverViewRoute;
}
Pubspec.yaml:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.3
stacked: ^1.7.1+1
auto_route: 0.6.1
stacked_services: 0.4.4+3
dev_dependencies:
build_runner: 1.10.0
auto_route_generator: 0.6.0
flutter_test:
sdk: flutter
Flutter doctor -v
✓] Flutter (Channel master, 1.20.0-8.0.pre.41, on Mac OS X 10.15.5 19F101, locale en-AU)
• Flutter version 1.20.0-8.0.pre.41 at /Users/mikaelwills/Documents/Flutter
• Framework revision fd80503fd3 (34 hours ago), 2020-07-10 14:41:02 +0530
• Engine revision 9b3e3410f0
• Dart version 2.9.0 (build 2.9.0-20.0.dev 06cb010247)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at /Users/mikaelwills/Library/Android/sdk
• Platform android-29, 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_202-release-1483-b49-5587405)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.5)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.5, Build version 11E608c
• CocoaPods version 1.8.4
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 3.5)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 42.1.1
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
[✓] VS Code (version 1.47.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.12.2
[✓] Connected device (2 available)
• Web Server (web) • web-server • web-javascript • Flutter Tools
• Chrome (web) • chrome • web-javascript • Google Chrome 83.0.4103.116
• No issues found!
Since the version 0.6.0 there were some breaking changes in the auto_route package, the most important was that It was changed the way routes are declared from class fields to a static list. You can check more details about it here.
So, in order to fix it just update it using a static list as follows:
#MaterialAutoRouter(
routes: <AutoRoute>[
MaterialRoute(page: StartupView, initial: true),
MaterialRoute(page: HomeView),
MaterialRoute(page: CoverView),
],
)
class $Router {}
and then run the build runner command: flutter pub run build_runner watch --delete-conflicting-outputs
Another option could be use an earlier version like the 0.5.0, but it's recommended to keep updated, for more info please check the documentation in theauto route package.

I have an error in vscode when trying to install flame under pubspec.yaml

I'm trying to install flame but whenever I run the pub get it gives me a really long error "Because every version of flutter_test from sdk depends on xml 3.6.1 and tiled >=0.4.0 depends on xml ^4.2.0, flutter_test from sdk is incompatible with tiled >=0.4.0." And then under it is a version solving failed error message.
[√] Flutter (Channel stable, v1.17.5, on Microsoft Windows [Version 10.0.18363.900], locale en-US)
• Flutter version 1.17.5 at C:\Users\marci\Downloads\flutter
• Framework revision 8af6b2f038 (7 days ago), 2020-06-30 12:53:55 -0700
• Engine revision ee76268252
• Dart version 2.8.4
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.0)
• Android SDK at C:\Users\marci\AppData\Local\Android\sdk
• Platform android-30, build-tools 30.0.0
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.
[√] Android Studio (version 4.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 47.1.2
• Dart plugin version 193.7361
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[√] VS Code (version 1.46.1)
• VS Code at C:\Users\marci\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.12.1
[!] Connected device
! No devices available
! Doctor found issues in 1 category.
name: ggg
description: A new Flutter project.
publish_to: 'none'
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.3
flame: ^0.24.0
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
I had the same problem today and checked on the Flame Discord channel.
They told me they have a conflict with their lib with stable flutter channel.
Recommendation is to change to Flutter Channel Beta.
I did that, then did Flutter Upgrade, then finally Flutter Pub Get and it worked.
Terminal Commands
To check which channel you are currently on
Flutter Channel
To change to the beta channel
Flutter Channel Beta
To get the beta version
Flutter Upgrade
So, when I have the same problem with you when I tried it.
Here's my solution:
In your dependencies: section inside the pubspec.yaml file, change the flame section without any version tag:
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.3
flame:

Images are not visible during flutter_driver tests

When running UI tests with flutter driver the assets are not displayed on iPhone simulator. They are displayed when app is run in debug mode from VS Code.
I tried to reproduce it on the example project generated by flutter create -i swift -a kotlin --androidx --org com.example example but without success. I followed exactly the same process of introducing flutter_driver tests in both apps according to this article. Unfortunately, in my app the images are not shown, and in example app they appear just fine. I compared project.pbxproj and pubspec.yaml files and they look fine to me.
For instance my pubspec.yaml:
dev_dependencies:
flutter_driver:
sdk: flutter
test: any
flutter_test:
sdk: flutter
screenshots:
flutter:
uses-material-design: true
assets:
- assets/lang/pl.json
- assets/images/
Is there anything that can help me with this issue? What can I do to debug the problem?
Logs
Beware, this is a very long log output.
flutter drive --target=test_driver/app.dart --verbose
https://gist.github.com/orestesgaolin/861c4f191773ca152b400d97ced2daeb
Flutter doctor
flutter doctor -v
[✓] Flutter (Channel stable, v1.7.8+hotfix.4, on Mac OS X 10.14.6 18G87, locale pl-PL)
• Flutter version 1.7.8+hotfix.4 at /Users/dominik/Library/flutter
• Framework revision 20e59316b8 (6 weeks ago), 2019-07-18 20:04:33 -0700
• Engine revision fee001c93f
• Dart version 2.4.0
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /Users/dominik/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-28, build-tools 28.0.3
• ANDROID_SDK_ROOT = /Users/dominik/Library/Android/sdk
• Java binary at: /Users/dominik/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/191.5791312/Android
Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 10.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 10.3, Build version 10G8
• CocoaPods version 1.7.5
[✓] iOS tools - develop for iOS devices
• ios-deploy 1.9.4
[✓] Android Studio (version 3.5)
• Android Studio at /Users/dominik/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/191.5791312/Android Studio.app/Contents
• Flutter plugin version 37.1.1
• Dart plugin version 183.6270
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
[✓] VS Code (version 1.37.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.3.0
[✓] Connected device (1 available)
• iPhone Xs Max • C1A5534A-AE3A-4FB3-95F6-993E351FF2D3 • ios • com.apple.CoreSimulator.SimRuntime.iOS-12-4 (simulator)
• No issues found!
So the solution was to create separate main_test.dart file that wraps whole app in DefaultAssetBundle like so:
runApp(DefaultAssetBundle(
bundle: TestAssetBundle(),
child: App(),
));
and TestAssetBundle is like so:
class TestAssetBundle extends CachingAssetBundle {
#override
Future<String> loadString(String key, {bool cache = true}) async {
final ByteData data = await load(key);
if (data == null) throw FlutterError('Unable to load asset');
return utf8.decode(data.buffer.asUint8List());
}
#override
Future<ByteData> load(String key) async => rootBundle.load(key);
}
And in app.dart you have to reference correct file:
import 'package:flutter_driver/driver_extension.dart';
import 'package:playoo_league_player/main_test.dart' as app;
void main() {
// This line enables the extension.
enableFlutterDriverExtension();
// Call the `main()` function of the app, or call `runApp` with
// any widget you are interested in testing.
app.main();
}
Full explanation can be found here: https://medium.com/#sardox.vl/flutter-test-and-randomly-missing-assets-in-goldens-ea959cdd336a
Those Images are not loading because of cache issues .For that we can
use
PRE CACHE IMAGES to preload the images
class App extends StatefulWidget {
#override
State<App> createState() => _AppState();
}
class _AppState extends State<App>{
late image image1
late image image2
#override
void initState() {
super.initState();
image1 = Image.asset('assets/images/');
image2 = Image.asset('assets/images/');
}
#override
void didChangeDependencies() {
pre cacheImage(image1.image, context);
pre cacheImage(image2.image, context);
super.didChangeDependencies();
}
#override
Widget build(BuildContext context) {
return Container
}
if it is multiple assets or images you can save this method as class and
initialise it from main.dart .

Flutter After Upgrade can't run application version solving failed

Nope. This answer doesn't work this time for me.
My flutter doctor -v
[✓] Flutter (Channel master, v0.5.9-pre.68, on Linux, locale en_US.UTF-8)
• Flutter version 0.5.9-pre.68 at /home/khophi/.flutterSetup
• Framework revision 5cd97f0004 (2 hours ago), 2018-08-16 14:10:22 -0700
• Engine revision 4ee648914f
• Dart version 2.1.0-dev.0.0.flutter-be6309690f
[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
• Android SDK at /home/khophi/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-27, build-tools 27.0.3
• ANDROID_HOME = /home/khophi/Android/sdk
• Java binary at: /usr/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_171-8u171-b11-0ubuntu0.18.04.1-b11)
• All Android licenses accepted.
[✗] Android Studio (not installed)
• Android Studio not found; download from https://developer.android.com/studio/index.html
(or visit https://flutter.io/setup/#android-setup for detailed instructions).
[✓] VS Code (version 1.26.0)
• VS Code at /usr/share/code
• Flutter extension version 2.17.1
[✓] Connected devices (1 available)
• klte • 956e8b90 • android-arm • Android 8.1.0 (API 27)
! Doctor found issues in 1 category.
When I run flutter run, I get:
Running "flutter packages get" in townsquare...
The current Dart SDK version is 2.1.0-dev.0.0.flutter-be6309690f.
Because flutter_circular_chart 0.0.3 requires SDK version >=1.19.0 <2.0.0 and no versions of flutter_circular_chart match >0.0.3 <0.1.0, flutter_circular_chart ^0.0.3 is forbidden.
So, because mobile depends on flutter_circular_chart ^0.0.3, version solving failed.
pub get failed (1)
This is my pubspec.yaml
name: mobile
description: A new Flutter project.
version: 1.0.0+1
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.2
carousel: ^0.0.1
http: "^0.11.3+16"
validate: "^1.6.0"
url_launcher: "^3.0.2"
shared_preferences: "^0.4.2"
font_awesome_flutter: "^7.0.0"
flutter_circular_chart: "^0.0.3"
flutter_local_notifications: ^0.3.6
dev_dependencies:
flutter_test:
sdk: flutter
assets:
- images/flutter.jpg
- images/logo.png
- images/bg_viewer.jpg
With the above, please enlighten me, what's wrong?
That's is because you are using : Dart version 2.1.0-dev.0.0.flutter-be6309690f and the plugin named flutter_circular_chart has a constraint
https://github.com/xqwzts/flutter_circular_chart/blob/master/pubspec.yaml
environment:
sdk: '>=1.19.0 <2.0.0'
You can fork the project and update the sdk constraint and ref to your repository:
Like this:
flutter_circular_chart:
git: https://github.com/your_repo/flutter_circular_chart.git
Note
Also would be fine if you open an issue in their repo to notify the devs about the issue that you have.
Use devendency_override with same version witch need for same for other dependency.
Like google_maps_flutter: ^0.5.28+1 needs intl to be 0.16.0
then craete dependency_overrides:
intl: ^0.16.0
below of dev_dependencies:
flutter_test:
sdk: flutter
run project until it not run on device.
Enjoy. Thanks..