Skip to content

Commit 624e5df

Browse files
authored
Merge pull request #235 from jamontes79/master
Add custom semantic label for progress
2 parents f878eba + e4b81cf commit 624e5df

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lib/src/introduction_screen.dart

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ library introduction_screen;
33
import 'dart:async';
44
import 'dart:math';
55

6-
import 'package:flutter/material.dart';
7-
86
import 'package:collection/collection.dart';
97
import 'package:dots_indicator/dots_indicator.dart';
8+
import 'package:flutter/material.dart';
109
import 'package:flutter_keyboard_visibility/flutter_keyboard_visibility.dart';
1110

1211
import '/src/helper.dart';
@@ -199,6 +198,9 @@ class IntroductionScreen extends StatefulWidget {
199198
/// Back button semantic label
200199
final String? backSemantic;
201200

201+
/// Progress indicator semantic label
202+
final String Function(int, int)? progressSemantic;
203+
202204
/// Enable or disable content resizing for bottom inset (e.g. keyboard)
203205
///
204206
/// @Default `true`
@@ -324,6 +326,7 @@ class IntroductionScreen extends StatefulWidget {
324326
this.nextSemantic,
325327
this.doneSemantic,
326328
this.backSemantic,
329+
this.progressSemantic,
327330
this.resizeToAvoidBottomInset = true,
328331
this.controlsPosition = const Position(left: 0, right: 0, bottom: 0),
329332
this.controlsMargin = EdgeInsets.zero,
@@ -680,7 +683,9 @@ class IntroductionScreenState extends State<IntroductionScreen> {
680683
child: widget.isProgress
681684
? widget.customProgress ??
682685
Semantics(
683-
label:
686+
label: widget.progressSemantic?.call(
687+
getCurrentPage() + 1,
688+
getPagesLength()) ??
684689
"Page ${getCurrentPage() + 1} of ${getPagesLength()}",
685690
excludeSemantics: true,
686691
child: DotsIndicator(

0 commit comments

Comments
 (0)