相似案例:flutter-web-app-blank-screen-in-release-mode
AWS EC2云服务器我在我的EC2服务器上构建了一个flutter web构建。并将flutter web index.html交叉连接到Nginx。
> $ flutter build web
💪 Building with sound null safety 💪
Compiling lib/main.dart for the Web... 1,491ms
所以EC2可以是200。
然后导航到另一个页面并刷新。
我的EC2服务器nginx配置是:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/flutter_web_project/build/web; # <- the flutter build web released result folder
index index.html index.htm index.nginx-debian.html;
server_name _;
location / {
try_files $uri $uri/ =404;
}
}
使用url_strategy dependency
dependencies:
flutter:
sdk: flutter
url_strategy: ^0.2.0
main.dart源代码:
...
import 'package:url_strategy/url_strategy.dart';
void main() {
setPathUrlStrategy();
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'flutter web sample',
theme: ThemeData(
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: locationPlatform(),
onGenerateRoute: WebRouter.generate,
initialRoute: '/',
);
}
...
2条答案
按热度按时间oyjwcjzk1#
更新nginx配置它将用于直接URL。
falq053o2#
更新nginx配置它将用于直接URL。
在以下行添加注解: