标签: flutter-web

修复 flutter webview 上的 net::err_unknown_url_scheme Whatsapp 链接

我想知道如何在 Flutterwebview应用程序中启动 WhatsApp 或从 Flutter 中的浏览器启动 WhatsApp,使用了许多代码,没有错误,但它们不起作用。我使用 mac m1 和 vscode

import 'package:coinpaga/Connectivity_Provider.dart';
import 'package:coinpaga/services/local_notification_service.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'homepage.dart';
import 'package:hexcolor/hexcolor.dart';
import 'package:colorful_safe_area/colorful_safe_area.dart';

///  Receive message when app is in background solution for on 
message
Future<void> backgroundHandler(RemoteMessage message)async{
  print(message.data.toString());
  print(message.notification!.title);
}
void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  LocalNotificationServices.initialize();
  await Firebase.initializeApp();
  FirebaseMessaging.onBackgroundMessage(backgroundHandler);
  runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
  Widget build(BuildContext context) {
return MultiProvider(
  providers: [
    ChangeNotifierProvider(
      create: (context) => ConnectivityProvider(),
      child: …
Run Code Online (Sandbox Code Playgroud)

android ios whatsapp flutter flutter-web

4
推荐指数
1
解决办法
2万
查看次数

如何从 Flutter Web 调用 JS 函数?

我有一个简单的 JS 函数,我想从 Flutter Web 应用程序调用它:

<script>
    function alertMessage(text) {
          alert(text)
    }
</script>
Run Code Online (Sandbox Code Playgroud)

我怎样才能实现这个目标?

主要.dart:

void onTap(){
    ///This is where I want to call the JS function...  alertMessage();
}
Run Code Online (Sandbox Code Playgroud)

javascript function dart flutter-web

4
推荐指数
1
解决办法
5260
查看次数

Flutter web:打开直接 URL 导航在本地工作但在部署后不起作用

我正在尝试在我的应用程序中实现 Flutter Web url 导航。当我尝试直接打开 http://localhost:7357/privacy-policy 时,它在我的本地计算机上打开正常,但是当我在服务器上部署后尝试直接打开相同的 URL 时,它不会加载并抛出错误。 在此输入图像描述 我正在使用 Firebase 来部署我的应用程序。

部署后,当我尝试通过主页访问而没有任何特定导航(例如www.example.com )时,一切正常,当我尝试直接访问页面www.example.com/privacy-policy时,就会出现错误浏览主页。

非常感谢任何帮助。谢谢。

navigation dart flutter flutter-dependencies flutter-web

4
推荐指数
1
解决办法
1437
查看次数

Flutter Web 不支持 Image.file。如何从 Flutter Web 的图库/相机获取图像?

在 Chrome 网络浏览器上运行 Flutter 应用程序时出现以下错误。我从图库中挑选了一张图片:

  Future getImage() async {
    try {
      final image = await ImagePicker().pickImage(source: ImageSource.gallery);
      if (image == null) {
        return;
      }
      final imageTemp = XFile(image.path);
      setState(() => this._userImage = imageTemp);
    } on PlatformException catch (e) {
      e.stacktrace;
    }
  }
Run Code Online (Sandbox Code Playgroud)

代码:

  dynamic getUserImage() {
    if (_userImage?.path == null) {
      return const Icon(
        Icons.person,
        color: Colors.grey,
        size: 54,
      );
    } else {
      return Image.file(File(_userImage!.path));
    }
  }
Run Code Online (Sandbox Code Playgroud)

图像:

在此输入图像描述

我应该使用或更改什么来从网络图库或相机中选择图像?

flutter flutter-web flutter-image-picker

4
推荐指数
1
解决办法
7888
查看次数

如何在 Flutter 中使用简写 IF 禁用单选按钮?

我有一个Radio,我想用一个条件禁用它,例如:

if (enabled == true){
*enable radio button*
} else {
*disable radio button*
}
Run Code Online (Sandbox Code Playgroud)

编辑

我将添加我的类的完整代码,因为我只添加了其中的一部分。

这是完整的代码:

if (enabled == true){
*enable radio button*
} else {
*disable radio button*
}
Run Code Online (Sandbox Code Playgroud)

flutter flutter-web

4
推荐指数
1
解决办法
2016
查看次数

Flutter:提供程序类中出现“构建期间调用 setState() 或 markNeedsBuild()”错误

我收到一个错误

\n

setState() or markNeedsBuild() called during build.

\n

我使用提供程序进行状态管理,在 Flutter (Web) 中开发了一个带有侧边栏的 Web 仪表板。

\n

这是完整的堆栈跟踪:

\n
Restarted application in 243ms.\nGleap already initialized.\n[GoRouter] Full paths for routes:\n             => /login\n[GoRouter] setting initial location /events\n[GoRouter] Using MaterialApp configuration\nUser is signed in!\n\xe2\x95\x90\xe2\x95\x90\xe2\x95\xa1 EXCEPTION CAUGHT BY FOUNDATION LIBRARY \xe2\x95\x9e\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\xe2\x95\x90\nThe following assertion was thrown while dispatching notifications for SidebarViewModel:\nsetState() or markNeedsBuild() called during build.\nThis _InheritedProviderScope<SidebarViewModel?> widget cannot be marked as needing to build because\nthe framework is already in the process of building widgets. A …
Run Code Online (Sandbox Code Playgroud)

provider flutter flutter-web

4
推荐指数
1
解决办法
7611
查看次数

Flutter Web使用哪个地图解决方案/软件包?

我正在将一个Flutter移动项目移植到Web上,并且很好奇要使用哪个地图包代替:

https://pub.dev/packages/google_maps_flutter

google-maps google-maps-markers flutter-web

3
推荐指数
2
解决办法
1904
查看次数

Display selected image in Flutter Web

Since flutter web is in tech preview, none of the plugins are working.

I have a task to show image, which we select. I have following picker

_startFilePicker() async {
InputElement uploadInput = FileUploadInputElement();
uploadInput.multiple = true;
uploadInput.click();

uploadInput.onChange.listen((e) {
  // read file content as dataURL
  final files = uploadInput.files;
  if (files.length == 1) {
    final file = files[0];
    final reader = FileReader();

    reader.onLoadEnd.listen((e) {
      _handleResult(reader.result);
          });
          reader.readAsDataUrl(file);
        }
      });
      }

        void _handleResult(Object result) {
          setState(() {
            images.add(result);
          });
        } …
Run Code Online (Sandbox Code Playgroud)

image file show flutter-web

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

运行Flutter Web时如何指定端口号

有什么方法可以始终在相同的指定端口号上启动具有Headless-Server目标的Flutter Web?

今天,通过以下方式运行Web应用程序:

flutter run -d headless-server
Run Code Online (Sandbox Code Playgroud)

提供一个随机的端口号。

flutter-web

3
推荐指数
6
解决办法
114
查看次数

我们可以在手机上通过 chrome 浏览器打开一个 Flutter Web 应用程序吗?

我创建了一个颤振 Web 应用程序。在选择设备时,我看到了 chrome 和我的设备等选项。我能够在它们两个中运行该应用程序。但是现在,我想通过手机上的 chrome 浏览器打开这个网络应用程序。怎么做?

dart flutter flutter-web

3
推荐指数
2
解决办法
2449
查看次数