title: Flutter - How to redirect to Homepage after user choose app's language?
body: <p>I'm building an app with Flutter source code. There is a menu name Change Language to let users can change app's language.</p>
  <p>After they pressed menu they will see a list of available languages then choosing a language. Nothing happen after choosing one nothing happen =&gt; they still see language list screen.</p>
  <p>Now I want to users be redirected to homepage after choosing a language. How can I do that?</p>
  <p>Here is the code to control language choosing.</p>
  <p>Thank you very much!!!</p>
  <pre><code>import 'package:easy_localization/easy_localization.dart';
  import 'package:flutter/material.dart';
  import 'package:myproject/constant/ps_dimens.dart';
  import 'package:myproject/constant/route_paths.dart';
  import 'package:myproject/provider/language/language_provider.dart';
  import 'package:myproject/repository/language_repository.dart';
  import 'package:myproject/ui/common/ps_admob_banner_widget.dart';
  import 'package:myproject/ui/common/ps_dropdown_base_widget.dart';
  import 'package:myproject/utils/utils.dart';
  import 'package:myproject/viewobject/common/language.dart';
  import 'package:google_mobile_ads/google_mobile_ads.dart';
  import 'package:provider/provider.dart';
  
  class LanguageSettingView extends StatefulWidget {
    const LanguageSettingView(
        {Key? key,
        required this.animationController,
        required this.languageIsChanged})
        : super(key: key);
    final AnimationController? animationController;
    final Function languageIsChanged;
    @override
    _LanguageSettingViewState createState() =&gt; _LanguageSettingViewState();
  }
  
  class _LanguageSettingViewState extends State&lt;LanguageSettingView&gt; {
    String currentLang = '';
    LanguageRepository? repo1;
  
    bool isConnectedToInternet = false;
    bool isSuccessfullyLoaded = true;
  
    void checkConnection() {
      Utils.checkInternetConnectivity().then((bool onValue) {
        isConnectedToInternet = onValue;
        if (isConnectedToInternet &amp;&amp; true) {
          setState(() {});
        }
      });
    }
  
    @override
    Widget build(BuildContext context) {
      if (!isConnectedToInternet &amp;&amp; true) {
        print('loading ads....');
        checkConnection();
      }
      final Animation&lt;double&gt; animation = Tween&lt;double&gt;(begin: 0.0, end: 1.0)
          .animate(CurvedAnimation(
              parent: widget.animationController!,
              curve: const Interval(0.5 * 1, 1.0, curve: Curves.fastOutSlowIn)));
      widget.animationController!.forward();
      // final dynamic data = EasyLocalizationProvider.of(context).data;
      final LanguageRepository repo1 = Provider.of&lt;LanguageRepository&gt;(context);
      // return EasyLocalizationProvider(
      //   data: data,
      //   child:
      return ChangeNotifierProvider&lt;LanguageProvider&gt;(
        lazy: false,
        create: (BuildContext context) {
          final LanguageProvider provider = LanguageProvider(repo: repo1);
        //  provider.getLanguageList();
          return provider;
        },
        child: Consumer&lt;LanguageProvider&gt;(builder:
            (BuildContext context, LanguageProvider provider, Widget? child) {
          return AnimatedBuilder(
              animation: widget.animationController!,
              child: SingleChildScrollView(
                  child: Container(
                padding: const EdgeInsets.all(PsDimens.space8),
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.start,
                  mainAxisSize: MainAxisSize.max,
                  crossAxisAlignment: CrossAxisAlignment.stretch,
                  children: &lt;Widget&gt;[
                    PsDropdownBaseWidget(
                        title: Utils.getString(
                            context, 'language_selection__select'),
                        selectedText: provider.getLanguage().name,
                        onTap: () async {
                          //provider.getLanguageList(); 
                          final dynamic result = await Navigator.pushNamed(
                              context, RoutePaths.languageList);
                          if (result != null &amp;&amp; result is Language) {
                            // EasyLocalization.of(context).set
                            // await data.changeLocale(result.toLocale());
  
                            // EasyLocalization.of(context).
  
                           await provider.addLanguage(result);
                           EasyLocalization.of(context)?.setLocale( Locale(result.languageCode!, result.countryCode));
                          }
                          Utils.psPrint(result.toString());
                        }),
                    const PsAdMobBannerWidget(
                      admobSize: AdSize.mediumRectangle,
                      // admobBannerSize: AdmobBannerSize.MEDIUM_RECTANGLE,
                    ),
                  ],
                ),
              )),
              builder: (BuildContext context, Widget? child) {
                return FadeTransition(
                    opacity: animation,
                    child: Transform(
                        transform: Matrix4.translationValues(
                            0.0, 100 * (1.0 - animation.value), 0.0),
                        child: child));
              });
        }),
        // ),
      );
    }
  }
  </code></pre>