@@ -95,10 +95,15 @@ class ThumbnailWidgetState extends State<ThumbnailWidget> {
9595
9696// ignore: must_be_immutable
9797class ScreenSelectDialog extends Dialog {
98- ScreenSelectDialog ({Key ? key}) : super (key: key) {
99- Future .delayed (const Duration (milliseconds: 100 ), () async {
100- await _getSources ();
101- });
98+ ScreenSelectDialog ({
99+ Key ? key,
100+ this .titleText = 'Choose what to share' ,
101+ this .screenTabText = 'Entire Screen' ,
102+ this .windowTabText = 'Window' ,
103+ this .cancelText = 'Cancel' ,
104+ this .shareText = 'Share' ,
105+ }) : super (key: key) {
106+ Timer (const Duration (milliseconds: 100 ), _getSources);
102107 _subscriptions.add (rtc.desktopCapturer.onAdded.stream.listen ((source) {
103108 _sources[source.id] = source;
104109 _stateSetter? .call (() {});
@@ -113,6 +118,13 @@ class ScreenSelectDialog extends Dialog {
113118 _stateSetter? .call (() {});
114119 }));
115120 }
121+
122+ final String titleText;
123+ final String screenTabText;
124+ final String windowTabText;
125+ final String cancelText;
126+ final String shareText;
127+
116128 final Map <String , rtc.DesktopCapturerSource > _sources = {};
117129 rtc.SourceType _sourceType = rtc.SourceType .Screen ;
118130 rtc.DesktopCapturerSource ? _selectedSource;
@@ -176,11 +188,11 @@ class ScreenSelectDialog extends Dialog {
176188 padding: const EdgeInsets .all (10 ),
177189 child: Stack (
178190 children: < Widget > [
179- const Align (
191+ Align (
180192 alignment: Alignment .topLeft,
181193 child: Text (
182- 'Choose what to share' ,
183- style: TextStyle (fontSize: 16 , color: Colors .black87),
194+ titleText ,
195+ style: const TextStyle (fontSize: 16 , color: Colors .black87),
184196 ),
185197 ),
186198 Align (
@@ -208,21 +220,20 @@ class ScreenSelectDialog extends Dialog {
208220 Container (
209221 constraints: const BoxConstraints .expand (height: 24 ),
210222 child: TabBar (
211- onTap: (value) async {
212- await Future .delayed (const Duration (milliseconds: 300 ));
213- _sourceType = value == 0 ? rtc.SourceType .Screen : rtc.SourceType .Window ;
214- await _getSources ();
215- },
216- tabs: const [
223+ onTap: (value) => Timer (const Duration (milliseconds: 300 ), () {
224+ _sourceType = value == 0 ? rtc.SourceType .Screen : rtc.SourceType .Window ;
225+ unawaited (_getSources ());
226+ }),
227+ tabs: [
217228 Tab (
218229 child: Text (
219- 'Entire Screen' ,
220- style: TextStyle (color: Colors .black54),
230+ screenTabText ,
231+ style: const TextStyle (color: Colors .black54),
221232 )),
222233 Tab (
223234 child: Text (
224- 'Window' ,
225- style: TextStyle (color: Colors .black54),
235+ windowTabText ,
236+ style: const TextStyle (color: Colors .black54),
226237 )),
227238 ]),
228239 ),
@@ -281,18 +292,18 @@ class ScreenSelectDialog extends Dialog {
281292 child: OverflowBar (
282293 children: < Widget > [
283294 MaterialButton (
284- child: const Text (
285- 'Cancel' ,
286- style: TextStyle (color: Colors .black54),
295+ child: Text (
296+ cancelText ,
297+ style: const TextStyle (color: Colors .black54),
287298 ),
288299 onPressed: () async {
289300 await _cancel (context);
290301 },
291302 ),
292303 MaterialButton (
293304 color: Theme .of (context).primaryColor,
294- child: const Text (
295- 'Share' ,
305+ child: Text (
306+ shareText ,
296307 ),
297308 onPressed: () async {
298309 await _ok (context);
0 commit comments