From 2510ac7f3e0cd093569d89fee2df39d525cb816c Mon Sep 17 00:00:00 2001 From: "susa.keyber" Date: Wed, 25 May 2022 05:50:51 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=80=20feat:=20=20Web=E3=81=AEUrlStrate?= =?UTF-8?q?gy=E3=81=AE=E8=A8=AD=E5=AE=9A=E3=82=92GoRouter=E3=81=AE?= =?UTF-8?q?=E6=A9=9F=E8=83=BD=E3=82=92=E4=BD=BF=E3=81=86=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue #143 --- lib/config/router.dart | 3 +++ lib/main.dart | 9 --------- lib/utils/url_strategy/url_strategy.dart | 6 ------ lib/utils/url_strategy/url_strategy_noop.dart | 7 ------- lib/utils/url_strategy/url_strategy_web.dart | 9 --------- 5 files changed, 3 insertions(+), 31 deletions(-) delete mode 100644 lib/utils/url_strategy/url_strategy.dart delete mode 100644 lib/utils/url_strategy/url_strategy_noop.dart delete mode 100644 lib/utils/url_strategy/url_strategy_web.dart diff --git a/lib/config/router.dart b/lib/config/router.dart index 21cd144a..b44bf5d5 100644 --- a/lib/config/router.dart +++ b/lib/config/router.dart @@ -85,6 +85,9 @@ final routerProvider = Provider( ), observers: [pageRouteObserver], debugLogDiagnostics: !kReleaseMode, + + // URLの#を除去する + urlPathStrategy: UrlPathStrategy.path, ), ); diff --git a/lib/main.dart b/lib/main.dart index e6b4f0c9..593fc874 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -3,25 +3,16 @@ // found in the LICENSE file. import 'package:flutter/material.dart'; -import 'package:flutter_cache_manager/flutter_cache_manager.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:hive_flutter/hive_flutter.dart'; import 'config/github_search_app.dart'; import 'localizations/strings.g.dart'; import 'repositories/hive/app_data_repository.dart'; -import 'utils/url_strategy/url_strategy.dart'; Future main() async { WidgetsFlutterBinding.ensureInitialized(); - // CacheManagerのログレベルを設定する - CacheManager.logLevel = CacheManagerLogLevel.none; - - // Web版のURLの#を除去する - // see: https://docs.flutter.dev/development/ui/navigation/url-strategies - usePathUrlStrategy(); - // fast_i18n の初期化 LocaleSettings.useDeviceLocale(); diff --git a/lib/utils/url_strategy/url_strategy.dart b/lib/utils/url_strategy/url_strategy.dart deleted file mode 100644 index 9873ce8a..00000000 --- a/lib/utils/url_strategy/url_strategy.dart +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright 2022 susatthi All rights reserved. -// Use of this source code is governed by a MIT license that can be -// found in the LICENSE file. - -// see: https://docs.flutter.dev/development/ui/navigation/url-strategies -export 'url_strategy_noop.dart' if (dart.library.html) 'url_strategy_web.dart'; diff --git a/lib/utils/url_strategy/url_strategy_noop.dart b/lib/utils/url_strategy/url_strategy_noop.dart deleted file mode 100644 index dbeb670f..00000000 --- a/lib/utils/url_strategy/url_strategy_noop.dart +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright 2022 susatthi All rights reserved. -// Use of this source code is governed by a MIT license that can be -// found in the LICENSE file. - -void usePathUrlStrategy() { - // noop -} diff --git a/lib/utils/url_strategy/url_strategy_web.dart b/lib/utils/url_strategy/url_strategy_web.dart deleted file mode 100644 index b376c01c..00000000 --- a/lib/utils/url_strategy/url_strategy_web.dart +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2022 susatthi All rights reserved. -// Use of this source code is governed by a MIT license that can be -// found in the LICENSE file. - -import 'package:flutter_web_plugins/flutter_web_plugins.dart'; - -void usePathUrlStrategy() { - setUrlStrategy(PathUrlStrategy()); -}