Skip to content

Commit

Permalink
Remove the deprecated widget 'WillPopScope'.
Browse files Browse the repository at this point in the history
  • Loading branch information
wanchao-xu committed Nov 17, 2023
1 parent 6d2fd9a commit 7480351
Showing 1 changed file with 78 additions and 85 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class _CallSampleState extends State<CallSample> {
@override
void deactivate() {
super.deactivate();
if (_inCalling) {
_hangUp();
}
_signaling?.close();
_localRenderer.dispose();
_remoteRenderer.dispose();
Expand Down Expand Up @@ -275,96 +278,86 @@ class _CallSampleState extends State<CallSample> {
]);
}

Future<bool> _onWillPop(BuildContext context) async {
if (_inCalling) {
_hangUp();
}
return true;
}

@override
Widget build(BuildContext context) {
return WillPopScope(
onWillPop: () => _onWillPop(context),
child: Scaffold(
appBar: AppBar(
title: Text(
'P2P Call Sample${_selfId != null ? ' [Your ID ($_selfId)] ' : ''}'),
actions: <Widget>[
IconButton(
icon: const Icon(Icons.settings),
onPressed: null,
tooltip: 'setup',
),
],
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
floatingActionButton: _inCalling
? SizedBox(
width: 240.0,
return Scaffold(
appBar: AppBar(
title: Text(
'P2P Call Sample${_selfId != null ? ' [Your ID ($_selfId)] ' : ''}'),
actions: <Widget>[
IconButton(
icon: const Icon(Icons.settings),
onPressed: null,
tooltip: 'setup',
),
],
),
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
floatingActionButton: _inCalling
? SizedBox(
width: 240.0,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
FloatingActionButton(
tooltip: 'Camera',
onPressed: _switchCamera,
child: const Icon(Icons.switch_camera),
),
FloatingActionButton(
tooltip: 'Screen Sharing',
onPressed: () => selectScreenSourceDialog(context),
child: const Icon(Icons.desktop_mac),
),
FloatingActionButton(
onPressed: _hangUp,
tooltip: 'Hangup',
backgroundColor: Colors.pink,
child: Icon(Icons.call_end),
),
FloatingActionButton(
tooltip: 'Mute Mic',
onPressed: _muteMic,
child: const Icon(Icons.mic_off),
)
]))
: null,
body: _inCalling
? OrientationBuilder(builder: (context, orientation) {
return Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
FloatingActionButton(
tooltip: 'Camera',
onPressed: _switchCamera,
child: const Icon(Icons.switch_camera),
),
FloatingActionButton(
tooltip: 'Screen Sharing',
onPressed: () => selectScreenSourceDialog(context),
child: const Icon(Icons.desktop_mac),
children: <Widget>[
Expanded(
flex: 1,
child: Container(
alignment: Alignment.center,
padding: const EdgeInsets.all(8.0),
decoration: BoxDecoration(color: Colors.black54),
child: RTCVideoView(_localRenderer),
),
FloatingActionButton(
onPressed: _hangUp,
tooltip: 'Hangup',
backgroundColor: Colors.pink,
child: Icon(Icons.call_end),
),
Expanded(
flex: 1,
child: Container(
alignment: Alignment.center,
padding: const EdgeInsets.all(8.0),
decoration: BoxDecoration(color: Colors.black54),
child: RTCVideoView(_remoteRenderer),
),
FloatingActionButton(
tooltip: 'Mute Mic',
onPressed: _muteMic,
child: const Icon(Icons.mic_off),
)
]))
: null,
body: _inCalling
? OrientationBuilder(builder: (context, orientation) {
return Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height,
child: Row(
children: <Widget>[
Expanded(
flex: 1,
child: Container(
alignment: Alignment.center,
padding: const EdgeInsets.all(8.0),
decoration: BoxDecoration(color: Colors.black54),
child: RTCVideoView(_localRenderer),
),
),
Expanded(
flex: 1,
child: Container(
alignment: Alignment.center,
padding: const EdgeInsets.all(8.0),
decoration: BoxDecoration(color: Colors.black54),
child: RTCVideoView(_remoteRenderer),
),
),
],
),
);
})
: ListView.builder(
shrinkWrap: true,
padding: const EdgeInsets.all(0.0),
itemCount: _peers.length,
itemBuilder: (context, i) {
return _buildRow(context, _peers[i]);
}),
),
),
],
),
);
})
: ListView.builder(
shrinkWrap: true,
padding: const EdgeInsets.all(0.0),
itemCount: _peers.length,
itemBuilder: (context, i) {
return _buildRow(context, _peers[i]);
}),
);
}
}

0 comments on commit 7480351

Please sign in to comment.