标签: flutter-web

如何让文件被选中

我正在使用旧版本构建一个颤振网络。我有一个 FileUploadInputElement。我需要从该元素中选择文件。

@override
  Widget build(BuildContext context) {
    FileUploadInputElement fileUploadInputElement = FileUploadInputElement();
    ui.platformViewRegistry.registerViewFactory(
        'animation-Image-html', (int viewId) => fileUploadInputElement);



    return SizedBox(
      child: HtmlElementView(
        viewType: 'animation-Image-html',
      ),
    );
}
Run Code Online (Sandbox Code Playgroud)

flutter-web

3
推荐指数
1
解决办法
4732
查看次数

Flutter Web 中的分段文件上传

有没有办法将文件分段上传到 Flutter Web 原生的服务器。因为 Flutter iOS 和 Android 有很多方法可以做到这一点。

flutter-web

3
推荐指数
1
解决办法
3158
查看次数

如何从已创建的移动应用程序添加用于 Web Flutter 的 Web 文件夹

我有这样的结构文件夹:

在此输入图像描述

我想使用 Flutter 在网络上显示我的移动应用程序。所以,我想为Flutter web添加文件夹web,我做了几种方法,但没有得到解决方案。 在此输入图像描述

我应该怎么做才能解决这个问题?

visual-studio-code flutter flutter-web

3
推荐指数
1
解决办法
7004
查看次数

如何让容器填充一行中的可用垂直空间?

谁能帮我吗?

我正在努力弄清楚如何让彩色容器延伸以匹配其行中最高的容器的高度。

目前,它们没有固定的高度/宽度,并被包裹在扩展小部件中以获得动态大小。

如果可能的话,我想保持它们的响应大小。我已经有一种方法可以在屏幕足够小时切换到列而不是行。一旦进入一列,我就可以使用,width: double.infinity因为没有水平滚动。

带容器的行

这是所使用的代码的示例(抱歉有这么多!):

class HomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Scrollbar(
        child: CustomScrollView(
          slivers: <Widget>[
            SliverNavBar(),
            SliverList(
              delegate: SliverChildListDelegate(
                [
                  Row(
                    crossAxisAlignment: CrossAxisAlignment.start,
                      children: _homePageContent(),
                     );
                  Footer()
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
Run Code Online (Sandbox Code Playgroud)
_homePageContent() {
  return <Widget>[
    _HomePageInfoBox(
      backgroundColor: accentColor,
      title: 'THIS IS A TITLE',
      body:
          'Lorem ipsum...',
    ),
    _HomePageInfoBox(
      backgroundColor: primaryColorDark,
      title: 'THIS IS A TITLE',
      body:
          'Lorem ipsum....',
    ),
    _HomePageInfoBox(
      backgroundColor: primaryColor,
      title: 'THIS …
Run Code Online (Sandbox Code Playgroud)

dart flutter flutter-layout flutter-web

3
推荐指数
1
解决办法
2163
查看次数

如何:默认显示 video_player 插件的播放控件 (flutter-web)

有什么方法可以默认显示视频播放器的控件吗?如果我在浏览器中右键单击视频,我就可以显示它们,所以我假设必须有一种默认显示的方法。

在此输入图像描述

dart flutter flutter-web

3
推荐指数
1
解决办法
3912
查看次数

如何:阻止 ListView 重建 video_player 小部件?

我已经设法让视频在 flutter-web 上播放,但是,当我滚动 ListView 中的视频时,视频将重建/重新加载。

当我滚动时,如何阻止视频播放器(在 ListView 中)被重建?

抱歉冗长的代码示例..我不知道如何进一步压缩它

任何帮助都会很棒!谢谢

import 'package:flutter/material.dart';
import '../../widgets/video/chewie_video.dart';
import 'package:video_player/video_player.dart';

class TestPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: ListView(
        children: <Widget>[
          Container(height: 1000),
          Center(
            child: ChewieVideo(
              videoPlayerController:
                  VideoPlayerController.asset('assets/video.mp4'),
            ),
          ),
          Container(height: 1000),
        ],
      ),
    );
  }
}
Run Code Online (Sandbox Code Playgroud)
import 'package:chewie/chewie.dart';
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';

class ChewieVideo extends StatefulWidget {
  final VideoPlayerController videoPlayerController;
  final bool looping;

  ChewieVideo({
    @required this.videoPlayerController,
    this.looping,
    Key key,
  }) : super(key: key);

  @override
  _ChewieVideoState createState() => _ChewieVideoState(); …
Run Code Online (Sandbox Code Playgroud)

dart flutter flutter-web

3
推荐指数
1
解决办法
3142
查看次数

滚动页面视图

我想使用PageView垂直轴并使用鼠标滚动在页面之间移动,但是当我使用鼠标滚动时,页面不会滚动...只有当我单击并向上/向下滑动时,页面才会滚动。

有什么办法可以做到这一点吗?

我想保留财产pageSnapping: true

问题:

当我尝试用鼠标滚动页面时,它不会改变,只是回到初始偏移量。但是当我点击并滑动时...

问题示例

class Body extends StatefulWidget {

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

class _BodyState extends State<Body> {
  PageController _controller = PageController(keepPage: true);

  @override
  void initState() {
    super.initState();
 }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        height: Sizing.size.height,
        width: Sizing.size.width,
        child: Stack(
          children: <Widget>[
            PageView(
              scrollDirection: Axis.vertical,
              controller: _controller,
              children: <Widget>[
                Container(color: Colors.red),
                Container(color: Colors.blue),
                Container(color: Colors.orange),
              ],
            ),
          ],
        ),
      ),
    );
  }
}
Run Code Online (Sandbox Code Playgroud)

flutter flutter-web

3
推荐指数
1
解决办法
8166
查看次数

Flutter Web中如何获取本地IP

我正在尝试在 Flutter Web 应用程序中获取本地 IP 地址。在互联网上搜索我发现了这个包:get_ip0.4.0 - 它声明它在网络下工作。

我有这个功能:

Future<void> initPlatformState() async {
    print("Test");
    String ipAddress;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      ipAddress = await GetIp.ipAddress;
    } on PlatformException {
      ipAddress = 'Failed to get ipAddress.';
    } on Exception {
      print("Exception");
    }

    print("Ip: $ipAddress");
  }
Run Code Online (Sandbox Code Playgroud)

我把它initState称为main.dart

控制台只有输出Test,不输出IP或Exception.

有人已经用过这个包了吗?Web 应用程序是否有其他方式获取本地 IP?

(我使用的是MacOS)

ip-address flutter flutter-web

3
推荐指数
1
解决办法
5887
查看次数

我可以在 Flutter web 上使用两个 iframe 吗?

我是 Flutter 的新手,正在开发一个用于学习的小网页。我想使用两个 iframe 放置谷歌地图和 Facebook feed。

我的代码基于 Wangoo 的代码: https ://medium.com/flutter-community/flutter-web-and-iframe-f26399aa1e2a

如果我只使用一个 iframe,它工作完美,但如果我使用第二个 iframe,它具有第一个 iframe 的源,而第一个 iframe 不显示任何内容。像这样: https: //i.stack.imgur.com/irTyY.jpg

已经测试了其他一些软件包,但大多数与网络不兼容,或者只是无法使用带有像这些链接的 iframe

这是我的代码:

import 'package:flutter/material.dart';

//ignore: avoid_web_libraries_in_flutter
import 'dart:html';
import 'dart:ui' as ui;

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Flutter Demo',
      theme: new ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: new MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : …
Run Code Online (Sandbox Code Playgroud)

iframe dart dart-html flutter flutter-web

3
推荐指数
1
解决办法
7417
查看次数

TypeError:无法读取未定义错误的属性“app” - Flutter 在 Flutter Web 应用程序中使用 firebase Auth 和 Firestore

 Running with sound null safety 
TypeError: Cannot read property 'app' of undefined
    at Object.app$ [as app] (http://localhost:49841/packages/firebase_core_web/src/interop/core.dart.lib.js:42:101)
    at new cloud_firestore_web.FirebaseFirestoreWeb.new (http://localhost:49841/packages/cloud_firestore_web/src/write_batch_web.dart.lib.js:988:64)
    at Function.registerWith (http://localhost:49841/packages/cloud_firestore_web/src/write_batch_web.dart.lib.js:842:73)
    at Object.registerPlugins (http://localhost:49841/packages/nse7a/generated_plugin_registrant.dart.lib.js:33:46)
    at main (http://localhost:49841/web_entrypoint.dart.lib.js:41:35)
    at main.next (<anonymous>)
    at runBody (http://localhost:49841/dart_sdk.js:37229:34)
    at Object._async [as async] (http://localhost:49841/dart_sdk.js:37260:7)
    at main$ (http://localhost:49841/web_entrypoint.dart.lib.js:40:18)
    at http://localhost:49841/main_module.bootstrap.js:19:10
    at Array.forEach (<anonymous>)
    at window.$dartRunMain (http://localhost:49841/main_module.bootstrap.js:18:32)
    at <anonymous>:1:8
    at Object.runMain (http://localhost:49841/dwds/src/injected/client.js:8656:21)
    at http://localhost:49841/dwds/src/injected/client.js:22068:19
    at _wrapJsFunctionForAsync_closure.$protected (http://localhost:49841/dwds/src/injected/client.js:3830:15)
    at _wrapJsFunctionForAsync_closure.call$2 (http://localhost:49841/dwds/src/injected/client.js:10905:12)
    at Object._asyncStartSync (http://localhost:49841/dwds/src/injected/client.js:3794:20)
    at main__closure1.$call$body$main__closure (http://localhost:49841/dwds/src/injected/client.js:22080:16)
    at main__closure1.call$1 (http://localhost:49841/dwds/src/injected/client.js:22007:19)
    at StaticClosure._rootRunUnary [as call$2$5] (http://localhost:49841/dwds/src/injected/client.js:4153:16)
    at …
Run Code Online (Sandbox Code Playgroud)

web firebase flutter flutter-web

3
推荐指数
1
解决办法
5020
查看次数