Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit d513946

Browse files
authored
Cleanup in web_ui (#12307)
1 parent 2620bab commit d513946

File tree

2 files changed

+17
-18
lines changed

2 files changed

+17
-18
lines changed

lib/web_ui/lib/src/engine/browser_location.dart

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ part of engine;
88

99
// Some parts of this file were inspired/copied from the AngularDart router.
1010

11-
/// Ensures that [str] is prefixed with [leading]. If [str] is already prefixed,
12-
/// it'll be returned unchanged. If it's not, this function will prefix it.
11+
/// Ensures that `str` is prefixed with `leading`.
1312
///
14-
/// The [applyWhenEmpty] flag controls whether this function should prefix [str]
13+
/// If `str` is already prefixed, it'll be returned unchanged. If it's not,
14+
/// this function will prefix it.
15+
///
16+
/// The `applyWhenEmpty` flag controls whether this function should prefix `str`
1517
/// or not when it's an empty string.
1618
///
1719
/// ```dart
@@ -27,9 +29,10 @@ String ensureLeading(String str, String leading, {bool applyWhenEmpty = true}) {
2729
return str.startsWith(leading) ? str : '$leading$str';
2830
}
2931

30-
/// `LocationStrategy` is responsible for representing and reading route state
31-
/// from the browser's URL. At the moment, only one strategy is implemented:
32-
/// [HashLocationStrategy].
32+
/// [LocationStrategy] is responsible for representing and reading route state
33+
/// from the browser's URL.
34+
///
35+
/// At the moment, only one strategy is implemented: [HashLocationStrategy].
3336
///
3437
/// This is used by [BrowserHistory] to interact with browser history APIs.
3538
abstract class LocationStrategy {
@@ -61,14 +64,14 @@ abstract class LocationStrategy {
6164
/// to represent its state.
6265
///
6366
/// In order to use this [LocationStrategy] for an app, it needs to be set in
64-
/// [ui.window.webOnlyLocationStrategy]:
67+
/// [ui.window.locationStrategy]:
6568
///
6669
/// ```dart
6770
/// import 'package:flutter_web/material.dart';
6871
/// import 'package:flutter_web/ui.dart' as ui;
6972
///
7073
/// void main() {
71-
/// ui.window.webOnlyLocationStrategy = const ui.HashLocationStrategy();
74+
/// ui.window.locationStrategy = const ui.HashLocationStrategy();
7275
/// runApp(MyApp());
7376
/// }
7477
/// ```
@@ -124,8 +127,10 @@ class HashLocationStrategy extends LocationStrategy {
124127
return _waitForPopState();
125128
}
126129

127-
/// Waits until the next popstate event is fired. This is useful for example
128-
/// to wait until the browser has handled the `history.back` transition.
130+
/// Waits until the next popstate event is fired.
131+
///
132+
/// This is useful for example to wait until the browser has handled the
133+
/// `history.back` transition.
129134
Future<void> _waitForPopState() {
130135
final Completer<void> completer = Completer<void>();
131136
ui.VoidCallback unsubscribe;
@@ -137,10 +142,10 @@ class HashLocationStrategy extends LocationStrategy {
137142
}
138143
}
139144

140-
/// `PlatformLocation` encapsulates all calls to DOM apis, which allows the
145+
/// [PlatformLocation] encapsulates all calls to DOM apis, which allows the
141146
/// [LocationStrategy] classes to be platform agnostic and testable.
142147
///
143-
/// The `PlatformLocation` class is used directly by all implementations of
148+
/// The [PlatformLocation] class is used directly by all implementations of
144149
/// [LocationStrategy] when they need to interact with the DOM apis like
145150
/// pushState, popState, etc...
146151
abstract class PlatformLocation {

lib/web_ui/lib/src/engine/window.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,6 @@ class EngineWindow extends ui.Window {
8181
_browserHistory.locationStrategy = strategy;
8282
}
8383

84-
/// This setter is used by [WebNavigatorObserver] to update the url to
85-
/// reflect the [Navigator]'s current route name.
86-
set webOnlyRouteName(String routeName) {
87-
_browserHistory.setRouteName(routeName);
88-
}
89-
9084
@override
9185
void sendPlatformMessage(
9286
String name,

0 commit comments

Comments
 (0)