'Flutter Feature Discovery Not SHowing Overlay

I had built an application and I'm trying to show feature discovery but, It is not showing discovery. Also not showing any error.

Question I Referred To Solve Issue

Main.dart

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  SystemChrome.setPreferredOrientations([DeviceOrientation.portraitUp])
      .then((_) async {
    runApp(
      FeatureDiscovery(
        child: MaterialApp(
        home: SplashScreen(),
        ),
      ),
    );
  });
}

ServicesOffersReviewsPhotos.dart

class ServicesOffersReviewsPhotos extends StatefulWidget {
  @override
  _ServicesOffersReviewsPhotosState createState() =>
      _ServicesOffersReviewsPhotosState();
}
class _ServicesOffersReviewsPhotosState
    extends State<ServicesOffersReviewsPhotos>
    with SingleTickerProviderStateMixin {
  late TabController _controller;

  @override
  void initState() {
    _controller = TabController(length: 4, vsync: this, initialIndex: 0);
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: kOffWhiteBackGroundColor,
      appBar: AppBar(
        backgroundColor: kOffWhiteBackGroundColor,
        elevation: 0,
        leading: IconButton(
          icon: Icon(
            Icons.arrow_back_ios,
            color: kDarkGrey,
            size: MediaQuery.of(context).size.width*0.05,
          ),
          onPressed: () {
            Navigator.pop(context);
          },
        ),
        actions: [
          IconButton(
            icon: Icon(
              Icons.favorite_border,
              color: kDarkGrey,
              size: MediaQuery.of(context).size.width*0.05,
            ),
            onPressed: () {},
          ),
          IconButton(
            icon: Icon(
              Icons.share,
              color: kDarkGrey,
              size: MediaQuery.of(context).size.width*0.05,
            ),
            onPressed: () {},
          ),
        ],
      ),
      body: SafeArea(
        child: DescribedFeatureOverlay(
          featureId: 'add_item_feature_id', // Unique id that identifies this overlay.
          tapTarget: const Icon(Icons.add), // The widget that will be displayed as the tap target.
          title: Text('Add item'),
          description: Text('Tap the plus icon to add an item to your list.'),
          backgroundColor: Theme.of(context).primaryColor,
          targetColor: Colors.black,
          textColor: Colors.black,
          child: Column(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              children's...
            ],
          ),
        ),
      ),
    );
  }
}

My Application Flow

SplashScreen (PushReplacement) -> onBoardingScreen(PushReplacement) -> LoginScreen(PushReplacement) -> Home(push) -> ServicesOffersReviewsPhotos

I have tried placing feature discovery on the top of servicesoffersReviewsPhotos Scaffold but didn't get any output.

I have referred every blog on medium, youtube videos. But didn't found any solution.



Solution 1:[1]

Question's probably old and abandoned but I think Feature Discovery is a great plugin with a lot of potential so, here goes...

I had cause to use the feature discovery plugin and ran into the same issue. After hours of reading their documentation, it turns out that the reason it seems like nothing is happening is because once the feature is show cased once or twice, Feature discovery automatically records that you have seen it in the shared preferences without telling you.

So, you'll notice that when you uninstall the app completely and clear all data, feature discovery seems to work again the first few times until it saves to shared preference again and doesn't seem to work again. This is the expected behaviour in production environment as it saves you the hassle to writing an onComplete callback function that involves shared preferences.

For the sake of development, they provided this function

FeatureDiscovery.clearPreferences

It essentially deletes the shared preferences data. So you can see it as many times as you want.

But the neatest way to stop auto save to shared preferences is to set this

recordStepsInSharedPreferences: false,

or this

 persistenceProvider: NoPersistenceProvider(),

as an argument to the FeatureDiscovery widget like this

 home: FeatureDiscovery(
        recordStepsInSharedPreferences: false,
          child: DemoApp()
      ),

If none of these work, try using only the compulsory parameters of DescribedFeatureOverlay before adding optional parameters one by one and testing each to see the faulty code.

link to the pub

Cheers.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Moses