This repository was archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[connectivity_for_web] Fix JS Interop in release mode. #2869
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2cb3a21
Remove auto-generator script, since we don't use almost anything of i…
ditman 6bfadf4
Switch to getProperty instead of accessing properties directly when i…
ditman 43c8d71
Migrate to dart:html NetworkInformation API.
ditman 6429ff5
Bump version
ditman 3e38a71
Make package publishable again.
ditman dbb76d5
Make version check happy
ditman 3069f31
Overwrite onchange until we can free resources on hot restart.
ditman 5dde17d
Make analyzer happy
ditman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 0 additions & 78 deletions
78
packages/connectivity/connectivity_for_web/lib/src/generated/network_information_types.dart
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 6 additions & 11 deletions
17
packages/connectivity/connectivity_for_web/lib/src/utils/connectivity_result.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 9 additions & 44 deletions
53
packages/connectivity/connectivity_for_web/test/lib/src/connectivity_mocks.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,25 @@ | ||
import 'dart:html'; | ||
|
||
import 'package:connectivity_for_web/src/generated/network_information_types.dart' | ||
as dom; | ||
import 'package:mockito/mockito.dart'; | ||
|
||
/// A Mock implementation of the NetworkInformation API that allows | ||
/// for external modification of its values. | ||
class MockNetworkInformation extends dom.NetworkInformation { | ||
@override | ||
String type; | ||
|
||
@override | ||
String effectiveType; | ||
|
||
@override | ||
num downlink; | ||
|
||
@override | ||
num rtt; | ||
|
||
@override | ||
EventListener onchange; | ||
|
||
/// Constructor of mocked instances... | ||
MockNetworkInformation({ | ||
this.type, | ||
this.effectiveType, | ||
this.downlink, | ||
this.rtt, | ||
}); | ||
class MockNetworkInformation extends Mock implements NetworkInformation { | ||
/// The callback that will fire after the network information values change. | ||
Function onchange; | ||
|
||
/// Changes the desired values, and triggers the change event listener. | ||
void mockChangeValue({ | ||
String type, | ||
String effectiveType, | ||
num downlink, | ||
num rtt, | ||
}) { | ||
this.type = type ?? this.type; | ||
this.effectiveType = effectiveType ?? this.effectiveType; | ||
this.downlink = downlink ?? this.downlink; | ||
this.rtt = rtt ?? this.rtt; | ||
}) async { | ||
when(this.type).thenAnswer((_) => type); | ||
when(this.effectiveType).thenAnswer((_) => effectiveType); | ||
when(this.downlink).thenAnswer((_) => downlink); | ||
when(this.rtt).thenAnswer((_) => rtt); | ||
|
||
onchange(Event('change')); | ||
} | ||
|
||
@override | ||
void addEventListener(String type, listener, [bool useCapture]) {} | ||
|
||
@override | ||
bool dispatchEvent(Event event) { | ||
return true; | ||
} | ||
|
||
@override | ||
Events get on => null; | ||
|
||
@override | ||
void removeEventListener(String type, listener, [bool useCapture]) {} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was probably Dart telling me that there already existed a native
NetworkInformation
class, but I misinterpreted as "coming from different parts"