@@ -40,7 +40,7 @@ To do so, you can edit *main.dart* file by following the steps below:
40
40
dart` file. For this
41
41
example, here's code in a custom action named 'setStatusbarColor'.
42
42
43
- ``` dart
43
+ ``` js
44
44
// Automatic FlutterFlow imports
45
45
import ' /backend/backend.dart' ;
46
46
import ' /flutter_flow/flutter_flow_theme.dart' ;
@@ -88,7 +88,7 @@ You might want to lock the device orientation in portrait or landscape mode to p
88
88
To set the device orientation in landscape-only mode, [ create a custom action] ( custom-actions.md ) with the
89
89
following code and [ add it to a ` main.dart ` ] ( #edit-maindart ) file.
90
90
91
- ``` dart
91
+ ``` js
92
92
// Automatic FlutterFlow imports
93
93
import ' /backend/backend.dart' ;
94
94
import ' /flutter_flow/flutter_flow_theme.dart' ;
@@ -123,7 +123,7 @@ If you want to ensure that your app appropriately manages its lifecycle and hand
123
123
To do so, [ create a custom action] ( custom-actions.md ) with the following code and [ add it to a ` main.dart ` ] ( #edit-maindart ) file.
124
124
125
125
126
- ``` dart
126
+ ``` js
127
127
// Automatic FlutterFlow imports
128
128
import ' /backend/backend.dart' ;
129
129
import ' /flutter_flow/flutter_flow_theme.dart' ;
@@ -136,21 +136,22 @@ import 'package:flutter/material.dart';
136
136
137
137
Future onAppBackground () async {
138
138
// Add your function code here!
139
- WidgetsBinding.instance.addObserver(AppLifecycleObserver());
139
+ WidgetsBinding .instance .addObserver (AppLifecycleObserver ());
140
140
}
141
141
142
142
class AppLifecycleObserver with WidgetsBindingObserver {
143
143
@override
144
- void didChangeAppLifecycleState(AppLifecycleState state) {
145
- if (state == AppLifecycleState.resumed) {
144
+ void didChangeAppLifecycleState (AppLifecycleState state ) {
145
+ if (state == AppLifecycleState .resumed ) {
146
146
// Do something when app is resumed
147
- print('App is in foreground');
148
- } else if (state == AppLifecycleState.paused) {
147
+ print (' App is in foreground' );
148
+ } else if (state == AppLifecycleState .paused ) {
149
149
// Do something when app is paused
150
- print('App is in background');
151
- }
152
- }
150
+ print (' App is in background' );
151
+ }
152
+ }
153
153
}
154
+
154
155
```
155
156
<figure >
156
157

0 commit comments