I'm trying to use the package ShowoCaseView in a flutter application, here are the steps I've made :
GlobalKey _oneShowcaseKey = GlobalKey();
startShowCase() {
WidgetsBinding.instance.addPostFrameCallback((_) async {
ShowCaseWidget.of(context).startShowCase([_oneShowcaseKey]);
});
}
@override
void initState() {
startShowCase();
super.initState();
}
@override
Widget build(BuildContext context) {
super.build(context);
return ShowCaseWidget(
builder: Builder(
builder: (context) => Scaffold(
child: Showcase(
key: _oneShowcaseKey,
title: 'Menu',
description: 'Click here to see menu options',
child: Column())
)
this is the way I've implemented the package in my application, but I get this error :
[ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: Exception: Please provide ShowCaseView context
I also got issue.
I changed to write "ShowCaseWIdget" into parent widget as follows, this issue is solved.
class SolvedStatelessWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: ShowCaseWidget(
builder: Builder(builder: (context) => SolvedStatefulWidget())));
}
}
class SolvedStatefulWidget extends StatefulWidget {
@override
_SolvedStatefulWidgetState createState() => _SolvedStatefulWidgetState();
}
class _SolvedStatefulWidgetState extends State<SolvedStatefulWidget> {
GlobalKey _oneShowcaseKey = GlobalKey();
startShowCase() {
WidgetsBinding.instance.addPostFrameCallback((_) async {
ShowCaseWidget.of(context).startShowCase([_oneShowcaseKey]);
});
}
@override
void initState() {
startShowCase();
super.initState();
}
@override
Widget build(BuildContext context) {
super.build(context);
return yourWidget()
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With