Skip to content

Commit

Permalink
chore(flutter): disable method channel
Browse files Browse the repository at this point in the history
  • Loading branch information
p-mazhnik committed Jul 17, 2023
1 parent 68a7350 commit 10cac65
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions flutter_module/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ class MyHomePage extends StatefulWidget {
}

class _MyHomePageState extends State<MyHomePage> {
static const platform = MethodChannel('pavel/flutter');
static const MethodChannel? _channel = null; // MethodChannel('pavel/flutter');

int _counter = 0;
bool _received = false;

@override
void initState() {
platform.setMethodCallHandler((call) async {
_channel?.setMethodCallHandler((call) async {
if (call.method == 'setCounterValue') {
setState(() {
_received = true;
Expand All @@ -73,7 +73,7 @@ class _MyHomePageState extends State<MyHomePage> {
// called again, and so nothing would appear to happen.
_counter++;
});
platform.invokeMethod('incrementCounter', {'data': '$_counter'});
_channel?.invokeMethod('incrementCounter', {'data': '$_counter'});
}

@override
Expand All @@ -92,9 +92,7 @@ class _MyHomePageState extends State<MyHomePage> {
leading: IconButton(
icon: const Icon(Icons.arrow_back, color: Colors.black),
onPressed: () {
platform.invokeMethod('closeFlutterScreen');
// todo: web support
SystemNavigator.pop();
_channel?.invokeMethod('closeFlutterScreen');
},
),
),
Expand Down

0 comments on commit 10cac65

Please sign in to comment.