Don't know if this is the better form, but here's a contribution for a help system (those that shows tooltips with > Next, X Close and < Back buttons):
HelpSystem.instance.showHelp(context, [
HelpEntry(
key: _recommendedLoginButtonKey,
title: "Boas vindas!",
text: "Para manter teus cronogramas salvos, você precisa se autenticar.\n\n"
"Esta é a forma mais simples e fácil de se autenticar neste dispositivo:",
direction: TooltipDirection.up,
distance: 24,
),
if (Platform.isIOS)
HelpEntry(
key: _googleLoginButtonKey,
title: "Google",
text: "Caso você já tenha uma conta usando Google, use este botão para entrar",
direction: TooltipDirection.up,
distance: 24,
),
HelpEntry(
key: _facebookLoginButtonKey,
title: "Facebook",
text: "Caso você já tenha uma conta usando o Facebook, você pode se autenticar aqui.",
direction: TooltipDirection.up,
distance: 24,
),
HelpEntry(
key: _emailLoginButtonKey,
title: "E-mail e senha",
text: "Se você usa e-mail e senha para entrar, use este botão.",
direction: TooltipDirection.up,
distance: 24,
),
HelpEntry(
key: _findSchedulesButtonKey,
title: "Na dúvida?",
text: "Caso não se lembre que conta usou para o teu cronograma, podemos te ajudar.",
direction: TooltipDirection.up,
distance: 24,
),
HelpEntry(
key: _helpButtonKey,
title: "Ajuda",
text: "Os botões de ajuda mostram estas dicas e estão presentes na maioria das telas.",
direction: TooltipDirection.up,
distance: 24,
),
]);
import 'package:flutter/material.dart';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
import 'package:super_tooltip/super_tooltip.dart';
/* —————————————————————————————————————————————————————————————————————————— */
class HelpEntry {
HelpEntry({this.key, this.title, this.text, this.direction, this.distance});
final GlobalKey key;
final String title;
final String text;
final TooltipDirection direction;
final double distance;
SuperTooltip tooltip;
}
/* —————————————————————————————————————————————————————————————————————————— */
class HelpSystem {
const HelpSystem._();
static const HelpSystem instance = HelpSystem._();
/* —————————————————————————————————————————————————————————————————————————— */
void showHelp(BuildContext context, List<HelpEntry> entries) {
final theme = Theme.of(context);
for (var ct = 0; ct < entries.length; ct++) {
final entry = entries[ct];
final buttons = <Widget>[];
entry.tooltip = SuperTooltip(
backgroundColor: Colors.white.withOpacity(0.9),
hasShadow: false,
popupDirection: entry.direction,
arrowTipDistance: entry.distance,
outsideBackgroundColor: Colors.transparent,
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Padding(
padding: const EdgeInsets.all(8),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Text(entry.title, style: theme.textTheme.body2),
const SizedBox(height: 4),
Text(entry.text, style: theme.textTheme.caption),
],
),
),
Row(mainAxisAlignment: MainAxisAlignment.spaceBetween, children: buttons),
],
),
);
if (ct == 0) {
buttons.add(FlatButton.icon(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
icon: Icon(MdiIcons.close, size: 24, color: theme.primaryColor),
label: Text("FECHAR", style: theme.textTheme.caption),
onPressed: () {
entry.tooltip.close();
},
));
if (entries.length > 1) {
buttons.add(FlatButton.icon(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
icon: Icon(MdiIcons.chevronRight, size: 24, color: theme.primaryColor),
label: Text("AVANÇAR", style: theme.textTheme.caption),
onPressed: () {
entry.tooltip.close();
entries[ct + 1].tooltip.show(entries[ct + 1].key.currentContext);
},
));
}
entry.tooltip.show(entry.key.currentContext);
} else if (ct == entries.length - 1) {
buttons.add(FlatButton.icon(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
icon: Icon(MdiIcons.chevronLeft, size: 24, color: theme.primaryColor),
label: Text("VOLTAR", style: theme.textTheme.caption),
onPressed: () {
entry.tooltip.close();
entries[ct - 1].tooltip.show(entries[ct - 1].key.currentContext);
},
));
buttons.add(FlatButton.icon(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
icon: Icon(MdiIcons.close, size: 24, color: theme.primaryColor),
label: Text("CONCLUIR", style: theme.textTheme.caption),
onPressed: () {
entry.tooltip.close();
},
));
} else {
buttons.add(FlatButton.icon(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
icon: Icon(MdiIcons.chevronLeft, size: 24, color: theme.primaryColor),
label: Text("VOLTAR", style: theme.textTheme.caption),
onPressed: () {
entry.tooltip.close();
entries[ct - 1].tooltip.show(entries[ct - 1].key.currentContext);
},
));
buttons.add(FlatButton.icon(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
icon: Icon(MdiIcons.close, size: 24, color: theme.primaryColor),
label: Text("FECHAR", style: theme.textTheme.caption),
onPressed: () {
entry.tooltip.close();
},
));
buttons.add(FlatButton.icon(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
icon: Icon(MdiIcons.chevronRight, size: 24, color: theme.primaryColor),
label: Text("AVANÇAR", style: theme.textTheme.caption),
onPressed: () {
entry.tooltip.close();
entries[ct + 1].tooltip.show(entries[ct + 1].key.currentContext);
},
));
}
}
}
}