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.7k
[android_alarm_manager] Migrated android_alarm_manager to support null safety #75233 #3499
Merged
Merged
Changes from 3 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
acb99c3
Migrated android_alarm_manager to support null safety #75233
thisisamank 9e808fb
pubspec.yaml version code updated
thisisamank fc97a63
Implemented changes according to review
thisisamank ebeaaff
Update packages/android_alarm_manager/CHANGELOG.md
bkonyi a6325e1
Update packages/android_alarm_manager/pubspec.yaml
bkonyi 30ca955
Implemented changes accorrding to review
thisisamank bce067b
Migrate example dependencies
stuartmorgan-g 72fc862
Opt out the integration tests
stuartmorgan-g f0320c7
example compilation fix
stuartmorgan-g f69db1d
Update NNBD plugin list
stuartmorgan-g 0e56069
Fix nullability of callback lookup
stuartmorgan-g c7b9cfd
Standardize null bool handling
stuartmorgan-g 57cc469
Change version to 2.0 due to previous 1.0 compat commitment
stuartmorgan-g fde3cbc
Merge branch 'master' into android-alarm-manager-nnbd
stuartmorgan-g 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
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 |
|---|---|---|
|
|
@@ -22,7 +22,7 @@ const String isolateName = 'isolate'; | |
| final ReceivePort port = ReceivePort(); | ||
|
|
||
| /// Global [SharedPreferences] object. | ||
| SharedPreferences prefs; | ||
| SharedPreferences? prefs; | ||
|
||
|
|
||
| Future<void> main() async { | ||
| // TODO(bkonyi): uncomment | ||
|
|
@@ -35,8 +35,8 @@ Future<void> main() async { | |
| isolateName, | ||
| ); | ||
| prefs = await SharedPreferences.getInstance(); | ||
| if (!prefs.containsKey(countKey)) { | ||
| await prefs.setInt(countKey, 0); | ||
| if (!prefs!.containsKey(countKey)) { | ||
| await prefs!.setInt(countKey, 0); | ||
| } | ||
| runApp(AlarmManagerExampleApp()); | ||
| } | ||
|
|
@@ -54,8 +54,8 @@ class AlarmManagerExampleApp extends StatelessWidget { | |
| } | ||
|
|
||
| class _AlarmHomePage extends StatefulWidget { | ||
| _AlarmHomePage({Key key, this.title}) : super(key: key); | ||
| final String title; | ||
| _AlarmHomePage({Key? key, this.title}) : super(key: key); | ||
| final String? title; | ||
|
|
||
| @override | ||
| _AlarmHomePageState createState() => _AlarmHomePageState(); | ||
|
|
@@ -78,15 +78,15 @@ class _AlarmHomePageState extends State<_AlarmHomePage> { | |
| print('Increment counter!'); | ||
|
|
||
| // Ensure we've loaded the updated count from the background isolate. | ||
| await prefs.reload(); | ||
| await prefs!.reload(); | ||
|
|
||
| setState(() { | ||
| _counter++; | ||
| }); | ||
| } | ||
|
|
||
| // The background | ||
| static SendPort uiSendPort; | ||
| static SendPort? uiSendPort; | ||
|
|
||
| // The callback for our alarm | ||
| static Future<void> callback() async { | ||
|
|
@@ -107,7 +107,7 @@ class _AlarmHomePageState extends State<_AlarmHomePage> { | |
| final textStyle = Theme.of(context).textTheme.headline4; | ||
| return Scaffold( | ||
| appBar: AppBar( | ||
| title: Text(widget.title), | ||
| title: Text(widget.title!), | ||
|
||
| ), | ||
| body: Center( | ||
| child: Column( | ||
|
|
@@ -125,7 +125,7 @@ class _AlarmHomePageState extends State<_AlarmHomePage> { | |
| style: textStyle, | ||
| ), | ||
| Text( | ||
| prefs.getInt(countKey).toString(), | ||
| prefs!.getInt(countKey).toString(), | ||
| key: ValueKey('BackgroundCountText'), | ||
| style: textStyle, | ||
| ), | ||
|
|
@@ -140,7 +140,7 @@ class _AlarmHomePageState extends State<_AlarmHomePage> { | |
| await AndroidAlarmManager.oneShot( | ||
| const Duration(seconds: 5), | ||
| // Ensure we have a unique alarm ID. | ||
| Random().nextInt(pow(2, 31)), | ||
| Random().nextInt(pow(2, 31).toInt()), | ||
| callback, | ||
| exact: true, | ||
| wakeup: true, | ||
|
|
||
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
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.
Uh oh!
There was an error while loading. Please reload this page.