Skip to main content

focusTarget method

TargetFocus focusTarget (GlobalKey<State<StatefulWidget>> key, String keyName, String description, {bool isCircle = false, ContentAlign align = ContentAlign.bottom, CrossAxisAlignment crossAlign = CrossAxisAlignment.start, Alignment skipAlignment = Alignment.topRight, Function? next, CrossAxisAlignment nextCrossAlign = CrossAxisAlignment.end, bool isEnd = false})

This returns a widget for a step in a tutorial.

params:

  • key: key of type GlobalKey.
  • keyName: key where the widget shows.
  • description: description of the step.
  • isCircle: bool to specify if circle
  • align: align of type ContentAlign to align button.
  • crossAlign: Cross align axes
  • skipAlignment: to give alignment of skip option
  • next: Functiontype, this show the next step orkey` to show the tour of.
  • nextCrossAlign: nextCrossAlign to give alignment of next option
  • isEnd: true if last step of the tour.

returns:

  • TargetFocus: This return widget foa a step in a tut

Implementation

TargetFocus focusTarget(
GlobalKey key,
String keyName,
String description, {
bool isCircle = false,
ContentAlign align = ContentAlign.bottom,
CrossAxisAlignment crossAlign = CrossAxisAlignment.start,
Alignment skipAlignment = Alignment.topRight,
Function? next,
CrossAxisAlignment nextCrossAlign = CrossAxisAlignment.end,
bool isEnd = false,
}) {
return TargetFocus(
enableOverlayTab: true,
color: Colors.transparent,
identify: keyName,
keyTarget: key,
alignSkip: skipAlignment,
shape: isCircle ? ShapeLightFocus.Circle : ShapeLightFocus.RRect,
contents: [
TargetContent(
align: align,
builder: (context, controller) {
return Container(
child: Column(
mainAxisSize: MainAxisSize.max,
crossAxisAlignment: crossAlign,
children: <Widget>[
Text(
description,
style: TextStyle(
color: Theme.of(context).colorScheme.background,
fontSize: 20,
),
),
],
),
);
},
),
TargetContent(
align: ContentAlign.custom,
customPosition: CustomTargetContentPosition(
bottom: SizeConfig.screenHeight! * 0.025,
),
builder: (context, controller) {
return GestureDetector(
onTap: () {
if (next != null) {
// ignore: avoid_dynamic_calls
next();
}
tutorialCoachMark.next();
},
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: nextCrossAlign,
children: <Widget>[
Text(
isEnd ? 'COMPLETE' : 'NEXT',
style: TextStyle(
color: Theme.of(context).colorScheme.background,
fontSize: 20,
),
),
],
),
);
},
),
],
);
}