Skip to content

Commit

Permalink
添加desktop_window插件
Browse files Browse the repository at this point in the history
  • Loading branch information
simplezhli committed May 27, 2021
1 parent 28b4004 commit 5bb5089
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
5 changes: 5 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import 'package:flutter_deer/util/handle_error_utils.dart';
import 'package:flutter_deer/util/log_utils.dart';
import 'package:flutter_deer/util/theme_utils.dart';
import 'package:flutter_gen/gen_l10n/deer_localizations.dart';
import 'package:desktop_window/desktop_window.dart';
import 'package:oktoast/oktoast.dart';
import 'package:flutter_deer/home/splash_page.dart';
import 'package:provider/provider.dart';
Expand Down Expand Up @@ -43,6 +44,10 @@ Future<void> main() async {
SystemChrome.setEnabledSystemUIOverlays([SystemUiOverlay.bottom]);
// TODO(weilu): 启动体验不佳。状态栏、导航栏在冷启动开始的一瞬间为黑色,且无法通过隐藏、修改颜色等方式进行处理。。。
// 相关问题跟踪:https://github.com/flutter/flutter/issues/73351
/// 设置桌面端窗口大小
if (Device.isDesktop) {
await DesktopWindow.setWindowSize(const Size(400, 800));
}
}

class MyApp extends StatelessWidget {
Expand Down
6 changes: 4 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ dependencies:
# 启动URL的插件(支持Web) https://github.com/flutter/plugins/tree/master/packages/url_launcher
url_launcher: 6.0.4
# 图片选择插件(支持Web) https://github.com/flutter/plugins/tree/master/packages/image_picker
image_picker: 0.7.5+2
image_picker: 0.7.5+3
# 侧滑删除 https://github.com/letsar/flutter_slidable
flutter_slidable: ^0.6.0
# WebView插件 https://github.com/flutter/plugins/tree/master/packages/webview_flutter
Expand All @@ -62,6 +62,8 @@ dependencies:
vibration: ^1.7.4-nullsafety.0
# 获取当前设备信息 https://github.com/flutter/plugins/tree/master/packages/device_info
device_info: 2.0.1
# 改变桌面端窗口大小(MacOS/Linux/Windows) https://github.com/mix1009/desktop_window
desktop_window: 0.4.0
# 高德2D地图插件(支持Web) https://github.com/simplezhli/flutter_2d_amap
flutter_2d_amap:
git:
Expand Down Expand Up @@ -93,7 +95,7 @@ dev_dependencies:
# flutter_goldens:
# sdk: flutter
# 单元测试
test: ^1.16.5
test: ^1.16.8

# For information on the generic Dart part of this file, see the
# following page: https:/w.dartlang.org/tools/pub/pubspec
Expand Down
3 changes: 3 additions & 0 deletions windows/flutter/generated_plugin_registrant.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@

#include "generated_plugin_registrant.h"

#include <desktop_window/desktop_window_plugin.h>
#include <url_launcher_windows/url_launcher_plugin.h>

void RegisterPlugins(flutter::PluginRegistry* registry) {
DesktopWindowPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("DesktopWindowPlugin"));
UrlLauncherPluginRegisterWithRegistrar(
registry->GetRegistrarForPlugin("UrlLauncherPlugin"));
}
1 change: 1 addition & 0 deletions windows/flutter/generated_plugins.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#

list(APPEND FLUTTER_PLUGIN_LIST
desktop_window
url_launcher_windows
)

Expand Down

0 comments on commit 5bb5089

Please sign in to comment.