我想知道如何在 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) 我有一个简单的 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) 我正在尝试在我的应用程序中实现 Flutter Web url 导航。当我尝试直接打开 http://localhost:7357/privacy-policy 时,它在我的本地计算机上打开正常,但是当我在服务器上部署后尝试直接打开相同的 URL 时,它不会加载并抛出错误。
我正在使用 Firebase 来部署我的应用程序。
部署后,当我尝试通过主页访问而没有任何特定导航(例如www.example.com )时,一切正常,当我尝试直接访问页面www.example.com/privacy-policy时,就会出现错误浏览主页。
非常感谢任何帮助。谢谢。
在 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)
图像:
我应该使用或更改什么来从网络图库或相机中选择图像?
我有一个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) 我收到一个错误
\nsetState() or markNeedsBuild() called during build.
我使用提供程序进行状态管理,在 Flutter (Web) 中开发了一个带有侧边栏的 Web 仪表板。
\n这是完整的堆栈跟踪:
\nRestarted 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) 我正在将一个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) 有什么方法可以始终在相同的指定端口号上启动具有Headless-Server目标的Flutter Web?
今天,通过以下方式运行Web应用程序:
flutter run -d headless-server
Run Code Online (Sandbox Code Playgroud)
提供一个随机的端口号。
我创建了一个颤振 Web 应用程序。在选择设备时,我看到了 chrome 和我的设备等选项。我能够在它们两个中运行该应用程序。但是现在,我想通过手机上的 chrome 浏览器打开这个网络应用程序。怎么做?
flutter-web ×10
flutter ×6
dart ×3
android ×1
file ×1
function ×1
google-maps ×1
image ×1
ios ×1
javascript ×1
navigation ×1
provider ×1
show ×1
whatsapp ×1