title: Why is the CircularProgressIndicator not showing when loading data when the page opens?
body: <p>This post is hidden. You deleted this post just now.
  I have a page where I am getting data from a server via BloC. When the page opens, I check stateElectricvehicles.id == 0, and while the check passes, I have this value true and const EmptyDetails() is shown, after which the data is loaded. I need to show a CircularProgressIndicator while data is being loaded and validated. I tried to use the isLoading variable and change its value, but nothing worked, tell me how can I first show the CircularProgressIndicator when opening the page?</p>
  <p><strong>body</strong></p>
  <pre><code>Widget _child(Size size, BuildContext context, double topPadding) {
      return BlocBuilder&lt;MycarsCubit, MycarsState&gt;(
        builder: (context, stateElectricvehicles) {
          final ElectricvehiclesCubit cubit =
              BlocProvider.of&lt;ElectricvehiclesCubit&gt;(context);
          if (stateElectricvehicles is MycarsInitial) {
            carNumber.text = stateElectricvehicles.number;
            carNumber.selection = TextSelection.fromPosition(
              TextPosition(offset: carNumber.text.length),
            );
            isLoading = true;
            if (stateElectricvehicles.id == 0) {
              savedCarId = stateElectricvehicles.id;
              isLoading = false;
            }
  
            final SharedPrefs prefs = SharedPrefs();
            return FutureBuilder&lt;int?&gt;(
              future: prefs.getInt('USER_ID'),
              builder: (context, snapshot) {
                if (!snapshot.hasData) {
                  return Container();
                }
  
                return Padding(
                  padding: EdgeInsets.only(top: topPadding + 10),
                  child: Column(
                    children: [
                      Padding(
                        padding: const EdgeInsets.only(left: 30, right: 30),
                        child: BackstepWidget(
                          text: 'My EVs',
                          onBackPressed: () {
                            Routemaster.of(context).history.back();
                          },
                        ),
                      ),
                      const SizedBox(height: 10),
                      snapshot.data != null
                          ? CarList(
                              savedCarId: savedCarId,
                              onIndexChanged: (value) {
                                savedCarId = value;
                              },
                            )
                          : const SizedBox(),
                      const SizedBox(height: 30),
                      stateElectricvehicles.id == 0
                          ? isLoading
                              ? const CircularProgressIndicator()
                              : const EmptyDetails()
                          : snapshot.data != null
                              ? Expanded(
                                  child: SingleChildScrollView(
                                    child: Column(
                                      children: [
                                        Padding(
  </code></pre>
  <p><strong>bloc</strong></p>
  <pre><code>class MycarsCubit extends Cubit&lt;MycarsState&gt; {
    MycarsCubit()
        : super(MycarsInitial(
            model: '',
            number: '',,
          ));
  
    String model = '';
    String number = '';
    late CarModel? carModel;
  
    void clear() {
      model = '';
      number = '';
      carModel = null;
    }
  
    void change({
      required String modelText,
      required String numberText,
      required CarModel? carModelNew,
    }) {
      model = modelText;
      number = numberText;
      carModel = carModelNew;
      emit(MycarsInitial(
        model: model,
        number: number,
        carModel: carModel,
      ));
    }
  }
  </code></pre>
  <p><strong>state</strong></p>
  <pre><code>abstract class MycarsState {}
  
  class MycarsInitial extends MycarsState {
    String number;
    String type;
    CarModel? carModel;
  
    MycarsInitial({
      required this.number,
      required this.type,
      this.carModel,
    });
  }
  </code></pre>