Skip to content

Commit

Permalink
WebView Desktop Compatibility
Browse files Browse the repository at this point in the history
- Add compatibility for desktop builds.
  • Loading branch information
rayliverified committed Feb 24, 2024
1 parent 62dfcb9 commit 4f99ef8
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
11 changes: 7 additions & 4 deletions lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_website/components/colors.dart';
import 'package:flutter_website/ui/block_wrapper.dart';
import 'package:flutter_website/ui/carousel/carousel.dart';
import 'package:responsive_framework/responsive_framework.dart';
import 'package:universal_io/io.dart';

import 'ui/blocks.dart';

Expand Down Expand Up @@ -69,10 +71,11 @@ List<Widget> blocks = [
const BlockWrapper(LearnFromDevelopers()),
const BlockWrapper(WhoUsesFlutter()),
// Disabled codelab block for performance.
const ResponsiveVisibility(
hiddenConditions: [Condition.smallerThan(name: DESKTOP)],
child: BlockWrapper(FlutterCodelab()),
),
if (kIsWeb || Platform.isAndroid || Platform.isIOS)
const ResponsiveVisibility(
hiddenConditions: [Condition.smallerThan(name: DESKTOP)],
child: BlockWrapper(FlutterCodelab()),
),
const BlockWrapper(FlutterNewsRow()),
const BlockWrapper(InstallFlutter()),
const Footer(),
Expand Down
20 changes: 11 additions & 9 deletions lib/ui/blocks.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter_website/components/components.dart';
import 'package:flutter_website/utils/utils.dart';
import 'package:responsive_framework/responsive_framework.dart';
import 'package:universal_io/io.dart';
import 'package:video_player/video_player.dart';
import 'package:webview_flutter/webview_flutter.dart';

Expand Down Expand Up @@ -1028,16 +1030,16 @@ class _LearnFromDevelopersState extends State<LearnFromDevelopers> {
padding: const EdgeInsets.symmetric(horizontal: 25),
child: AspectRatio(
aspectRatio: videoAspectRatio,
child: WebViewWidget(
key: webViewKey,
controller: WebViewController()
..loadRequest(Uri.parse(videoUrl)),
)
child: (kIsWeb || Platform.isAndroid || Platform.isIOS)
? WebViewWidget(
key: webViewKey,
controller: WebViewController()
..loadRequest(Uri.parse(videoUrl)),
)
: Image.asset(
"assets/images/video_thumbnail_learn_from_developers.png",
fit: BoxFit.contain)
// TODO: Legacy WebView on Web workarounds.
// (kIsWeb)
// ? Image.asset(
// "assets/images/video_thumbnail_learn_from_developers.png",
// fit: BoxFit.contain)
// HtmlElementView(
// key: webViewKey,
// viewType: webViewKey.toString(),
Expand Down
2 changes: 1 addition & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ packages:
source: hosted
version: "2.2.4"
universal_io:
dependency: transitive
dependency: "direct main"
description:
name: universal_io
sha256: "1722b2dcc462b4b2f3ee7d188dad008b6eb4c40bbd03a3de451d82c78bba9aad"
Expand Down
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ dependencies:
webview_flutter_web: ^0.2.2+4
universal_html: ^2.2.4
google_fonts: ^6.1.0
universal_io: ^2.2.2
responsive_framework:
path: responsive_framework/

Expand Down
2 changes: 1 addition & 1 deletion windows/runner/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
FlutterWindow window(project);
Win32Window::Point origin(10, 10);
Win32Window::Size size(1280, 720);
if (!window.Create(L"flutter_website", origin, size)) {
if (!window.Create(L"Flutter.dev", origin, size)) {
return EXIT_FAILURE;
}
window.SetQuitOnClose(true);
Expand Down

0 comments on commit 4f99ef8

Please sign in to comment.