'initState() not show in Autosuggetion

I try to override initState() inside _SplashScreenState, but it not show in suggestions list, i try invalid catches/Restart too.

import 'package:coupfferapp/screen/home.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:shimmer/shimmer.dart';

class SplashScreen extends StatefulWidget {
@override
_SplashScreenState createState() => _SplashScreenState();

  }

   class _SplashScreenState extends State<SplashScreen> {



@override
 void initState() {
 super.initState();
_checkLoginSession().then((status) {
  _navigateToHome();
  });
}

Future<bool> _checkLoginSession() async {
await Future.delayed(Duration(microseconds: 5000), () {});
return true;
   }

void _navigateToHome() {
Navigator.of(context).pushReplacement(
    MaterialPageRoute(builder: (BuildContext context) => Home()));
}

 @override
 Widget build(BuildContext context) {
  return Scaffold(
  body: Container(
    child: Stack(
      alignment: Alignment.center,
      children: <Widget>[
        Container(
          color: Colors.white,
        ),
  //            Opacity(
  //                    opacity: .9,
  //                    child: Image.asset('images/splash.png', fit: 
   BoxFit.cover)),
        Shimmer.fromColors(
            child: Container(
              padding: EdgeInsets.all(16.0),
              child: Text(
                "Mayur",
                style: TextStyle(
                    fontSize: 90.0,
                    fontFamily: 'Calistoga',
                    shadows: <Shadow>[
                      Shadow(
                          blurRadius: 18.0,
                          color: Colors.black26,
                          offset: Offset.fromDirection(120, 12))
                    ]),
              ),
            ),
            baseColor: Colors.orange,
            highlightColor: Colors.red)
      ],
     ),
    ),
   );
  }
}


Solution 1:[1]

This is the way you have it in suggestion, maybe you put it in the wrong sort. It has to be outside the build function:

class _SplashScreenState extends State<SplashScreen> {

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }

 @override
 Widget build(BuildContext context) {

       }
}

Hope it helps!

Solution 2:[2]

Maybe sometimes it does not show you the overridden methods maybe you have type initial letters and click Ctrl+Space for windows and Cmd +space for Mac which forces it to find the methods. Let me know if it works

Solution 3:[3]

I had the same issue and I have just call my initState function from right above the build function. Let nothing comes between your initState() and build function.

 @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }
  
  @override
  Widget build(BuildContext context) {
    return isAuth ? buildAuthScreen() : buildUnAuthScreen();
  }

Solution 4:[4]

you need to type right above the build method otherwise the snippet won't appear.

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 Marcel Dz
Solution 2 Sagar Acharya
Solution 3 The Roob
Solution 4 Abraham