Control a menu with a button

Hello !
Here is my problem :
I have 2 code pages on my flutter app.

  1. home.dart :
import 'package:flutter/material.dart';
import 'package:bottom_navy_bar/bottom_navy_bar.dart';
import 'placeholder.dart';
import 'contact.dart';

Map<int, Color> color =
{
50:Color.fromRGBO(248,134,148, .1),
100:Color.fromRGBO(248,134,148, .2),
200:Color.fromRGBO(248,134,148, .3),
300:Color.fromRGBO(248,134,148, .4),
400:Color.fromRGBO(248,134,148, .5),
500:Color.fromRGBO(248,134,148, .6),
600:Color.fromRGBO(248,134,148, .7),
700:Color.fromRGBO(248,134,148, .8),
800:Color.fromRGBO(248,134,148, .9),
900:Color.fromRGBO(248,134,148, 1),
};
int currentIndex = 0;

MaterialColor colorCustom = MaterialColor(0xFFF88694, color);

class Home extends StatefulWidget {
Home({Key key, this.title}) : super(key: key);


final String title;

@override
_HomeState createState() => _HomeState();
}

class _HomeState extends State<Home> {

final List<Widget> _children = [
  Recipes(),
  PlaceholderWidget(Colors.deepOrange),
  PlaceholderWidget(Colors.green),
  Contact(),
  PlaceholderWidget(Colors.red)
];
int _counter = 0;

void _incrementCounter() {
  setState(() {
    _counter++;
  });
}

@override
Widget build(BuildContext context) {
  return Scaffold(
    appBar: AppBar(
      title: Text(widget.title),

    ),
    body: _children[currentIndex],
    bottomNavigationBar: BottomNavyBar(
      selectedIndex: currentIndex,
      showElevation: true,
      itemCornerRadius: 8,
      //iconSize: 30,
      curve: Curves.ease,
      onItemSelected: (index) => setState(() {
        currentIndex = index;
      }),
      items: [
        BottomNavyBarItem(
          icon: Icon(Icons.apps),
          title: Text('Recettes'),
          activeColor: HexColor('#F88694'),
          textAlign: TextAlign.center,
        ),
        BottomNavyBarItem(
          icon: Icon(Icons.add),
          title: Text('Nouveau'),
          activeColor: HexColor('#95C7DD'),
          textAlign: TextAlign.center,

        ),
        BottomNavyBarItem(
          icon: Icon(Icons.swap_vert),
          title: Text('Importer'),
          activeColor: HexColor('#FEBB6D'),
          textAlign: TextAlign.center,

        ),
        BottomNavyBarItem(
          icon: Icon(Icons.info),
          title: Text('Contact'),
          activeColor: HexColor('#F88694'),
          textAlign: TextAlign.center,

        ),
        BottomNavyBarItem(
          icon: Icon(Icons.settings),
          title: Text('Paramètres'),
          activeColor: HexColor('#95C7DD'),
          textAlign: TextAlign.center,
        ),
      ],
    ),
  );
}
void itemSelected (int index){
  setState(() {
    currentIndex = index;
  });
}

}
class HexColor extends Color {
static int _getColorFromHex(String hexColor) {
  hexColor = hexColor.toUpperCase().replaceAll("#", "");
  if (hexColor.length == 6) {
    hexColor = "FF" + hexColor;
  }
  return int.parse(hexColor, radix: 16);
}

HexColor(final String hexColor) : super(_getColorFromHex(hexColor));
} 
  1. recipes.dart:
import 'package:flutter/material.dart';
import 'package:nice_button/NiceButton.dart';


class Recipes extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    return Scaffold(

    body: Material(
      child: Center(

    child: SizedBox(
        width: 350,
    child: Column(
        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
        children: <Widget>[

          Text.rich(
            TextSpan(
              children: <TextSpan>[
                TextSpan(text: 'Bienvenue sur l\'application', style: TextStyle(fontWeight: FontWeight.w900, fontSize: 35, fontFamily: 'Indies')),
                TextSpan(text: ' Gluci', style: TextStyle(color: HexColor('#F88694'),fontWeight: FontWeight.w900, fontSize: 35, fontFamily: 'Indies')),
                TextSpan(text: '\' ', style: TextStyle(color: HexColor('#95C7DD'), fontWeight: FontWeight.w900, fontSize: 35, fontFamily: 'Indies')),
                TextSpan(text: 'Aide', style: TextStyle(color: HexColor('#FEBB6D'), fontWeight: FontWeight.w900, fontSize: 35, fontFamily: 'Indies')),
                TextSpan(text: ' !', style: TextStyle(fontWeight: FontWeight.w900, fontSize: 35, fontFamily: 'Indies')),
              ],

            ),
            textAlign: TextAlign.center,


        ),



          Text(
            'Calculez les glucides d\' une recette pour la voir apparaitre ici. N\'hésitez pas à naviguer dans les onglets en bas pour découvrir les différentes fonctionnalités de notre nouvelle application !',
            textAlign: TextAlign.center,
            softWrap: true,
            style: TextStyle(
              fontSize: 15,

            ),

          ),
          NiceButton(
            // width: 515,
            elevation: 40,
            radius: 8.0,
            text: "Ajouter une recette",
            background: HexColor('#95C7DD'),
            onPressed: () {
              print("hello");
            },
          ),
  ]
      ),
    ),
      ),
    ),
    );
  }
}

I’d like to replace the print("hello"); of the button in recipes.dart by an action that allows to access the second page of my home.dart navigation bar.

Do you have any suggestions? I didn’t find anything on google.
Thank You
rubidev68

P-S: Sorry for the quality of the English but it’s not my main language :wink:

Firstly, no need to apologise for bad English, I understand how challenging it can get. :slight_smile:

Now, let’s get to the question,

From what I understand is that you want to change the SelectedIndex of BottomNavBar in home.dart to the second item. I would suggest you to create a function in home.dart that changes the selected index and pass it to recipes.dart as an argument.

home.dart

void changeSelectedPage(int index) {
   setState(() {
       currentIndex = index;
   }) 
}

Pass this function as an argument to Recipes, you will have to change this to a Stateful Widget.
So the place where you are calling Recipes.dart call it like this: -

Recipes(changeSelectedPage);

class Recipes extends StatefulWidget {
  Function changeSelectedPage;
  Recipes(this.changeSelectedPage);
 }

Replace print("hello"); with widget.changeSelectedPage();

1 Like

Thank you very much @sakina for your prompt response. I tried to apply your method but I still have a small problem…
Here is y code :

  1. home.dart
import 'package:flutter/material.dart';
import 'package:bottom_navy_bar/bottom_navy_bar.dart';
import 'new.dart';
import 'placeholder.dart';
import 'contact.dart';

Map<int, Color> color =
{
  50:Color.fromRGBO(248,134,148, .1),
  100:Color.fromRGBO(248,134,148, .2),
  200:Color.fromRGBO(248,134,148, .3),
  300:Color.fromRGBO(248,134,148, .4),
  400:Color.fromRGBO(248,134,148, .5),
  500:Color.fromRGBO(248,134,148, .6),
  600:Color.fromRGBO(248,134,148, .7),
  700:Color.fromRGBO(248,134,148, .8),
  800:Color.fromRGBO(248,134,148, .9),
  900:Color.fromRGBO(248,134,148, 1),
};
int currentIndex = 0;

MaterialColor colorCustom = MaterialColor(0xFFF88694, color);

class Home extends StatefulWidget {
  Home({Key key, this.title}) : super(key: key);


  final String title;

  @override
  _HomeState createState() => _HomeState();
}

class _HomeState extends State<Home> {
  void changeSelectedPage(int index) {
    setState(() {
      currentIndex = index;
    });
  }

  final List<Widget> _children = [
    Recipes(changeSelectedPage),
    PlaceholderWidget(Colors.green),
    PlaceholderWidget(Colors.green),
    Contact(),
    PlaceholderWidget(Colors.red)
  ];
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),

      ),
      body: _children[currentIndex],
      bottomNavigationBar: BottomNavyBar(
        selectedIndex: currentIndex,
        showElevation: true,
        itemCornerRadius: 8,
        //iconSize: 30,
        curve: Curves.ease,
        onItemSelected: (index) => setState(() {
          currentIndex = index;
        }),
        items: [
          BottomNavyBarItem(
            icon: Icon(Icons.apps),
            title: Text('Recettes'),
            activeColor: HexColor('#F88694'),
            textAlign: TextAlign.center,
          ),
          BottomNavyBarItem(
            icon: Icon(Icons.add),
            title: Text('Nouveau'),
            activeColor: HexColor('#95C7DD'),
            textAlign: TextAlign.center,

          ),
          BottomNavyBarItem(
            icon: Icon(Icons.swap_vert),
            title: Text('Importer'),
            activeColor: HexColor('#FEBB6D'),
            textAlign: TextAlign.center,

          ),
          BottomNavyBarItem(
            icon: Icon(Icons.info),
            title: Text('Contact'),
            activeColor: HexColor('#F88694'),
            textAlign: TextAlign.center,

          ),
          BottomNavyBarItem(
            icon: Icon(Icons.settings),
            title: Text('Paramètres'),
            activeColor: HexColor('#95C7DD'),
            textAlign: TextAlign.center,
          ),
        ],
      ),
    );
  }
  


}
class HexColor extends Color {
  static int _getColorFromHex(String hexColor) {
    hexColor = hexColor.toUpperCase().replaceAll("#", "");
    if (hexColor.length == 6) {
      hexColor = "FF" + hexColor;
    }
    return int.parse(hexColor, radix: 16);
  }

  HexColor(final String hexColor) : super(_getColorFromHex(hexColor));
} 
  1. recipes.dart
import 'package:flutter/material.dart';
import 'package:nice_button/NiceButton.dart';

class Recipes extends StatefulWidget {

  Function changeSelectedPage;
  Recipes({Key key, this.changeSelectedPage}) : super(key: key);

  @override
  _RecipesState createState() => _RecipesState();

}

class _RecipesState extends State<Recipes> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(

    body: Material(
      child: Center(

    child: SizedBox(
        width: 350,
    child: Column(
        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
        children: <Widget>[

          Text.rich(
            TextSpan(
              children: <TextSpan>[
                TextSpan(text: 'Bienvenue sur l\'application', style: TextStyle(fontWeight: FontWeight.w900, fontSize: 35, fontFamily: 'Indies')),
                TextSpan(text: ' Gluci', style: TextStyle(color: HexColor('#F88694'),fontWeight: FontWeight.w900, fontSize: 35, fontFamily: 'Indies')),
                TextSpan(text: '\' ', style: TextStyle(color: HexColor('#95C7DD'), fontWeight: FontWeight.w900, fontSize: 35, fontFamily: 'Indies')),
                TextSpan(text: 'Aide', style: TextStyle(color: HexColor('#FEBB6D'), fontWeight: FontWeight.w900, fontSize: 35, fontFamily: 'Indies')),
                TextSpan(text: ' !', style: TextStyle(fontWeight: FontWeight.w900, fontSize: 35, fontFamily: 'Indies')),
              ],

            ),
            textAlign: TextAlign.center,


        ),



          Text(
            'Calculez les glucides d\' une recette pour la voir apparaitre ici. N\'hésitez pas à naviguer dans les onglets en bas pour découvrir les différentes fonctionnalités de notre nouvelle application !',
            textAlign: TextAlign.center,
            softWrap: true,
            style: TextStyle(
              fontSize: 15,

            ),

          ),
          NiceButton(
            // width: 515,
            elevation: 40,
            radius: 8.0,
            text: "Ajouter une recette",
            background: HexColor('#95C7DD'),
            onPressed: () {
              widget.changeSelectedPage(2);
            },
          ),
  ]
      ),
    ),
      ),
    ),
    );
  }

  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    throw UnimplementedError();
  }
} 

I have two errors in main.dart on this line Recipes(changeSelectedPage), :
error: The instance member 'changeSelectedPage' can't be accessed in an initializer. (implicit_this_reference_in_initializer at [GluciAide4] lib\home.dart:43) and
Error: Can't access 'this' in a field initializer to read 'changeSelectedPage'.

Thank You
rubidev68

Heyy @rubidev68

Sorry for the late reply. Try this:

Initialize the _children list as an empty list.

List<Widget> _children = [];

*Notice final keyword is not used.

Then, in initState add the items to the list.

  @override
  void initState(BuildContext context) {
     _children = [
       Recipes(changeSelectedPage),
       PlaceholderWidget(Colors.green),
       PlaceholderWidget(Colors.green),
       Contact(),
       PlaceholderWidget(Colors.red)
     ]; 
  }

Let me know if it works out.

Thanks @sakina.
While looking for the solution to another problem, I also managed to solve this one with this: https://hillel.dev/2018/08/15/flutter-how-to-rebuild-the-entire-app-to-change-the-theme-or-locale/ and this code :

  1. home.dart
import 'package:flutter/material.dart';
import 'package:bottom_navy_bar/bottom_navy_bar.dart';
import 'new.dart';
import 'placeholder.dart';
import 'contact.dart';

Map<int, Color> color =
{
  50:Color.fromRGBO(248,134,148, .1),
  100:Color.fromRGBO(248,134,148, .2),
  200:Color.fromRGBO(248,134,148, .3),
  300:Color.fromRGBO(248,134,148, .4),
  400:Color.fromRGBO(248,134,148, .5),
  500:Color.fromRGBO(248,134,148, .6),
  600:Color.fromRGBO(248,134,148, .7),
  700:Color.fromRGBO(248,134,148, .8),
  800:Color.fromRGBO(248,134,148, .9),
  900:Color.fromRGBO(248,134,148, 1),
};
int currentIndex = 0;

MaterialColor colorCustom = MaterialColor(0xFFF88694, color);

class AppBuilder extends StatefulWidget {
  final Function(BuildContext) builder;

  const AppBuilder(
      {Key key, this.builder})
      : super(key: key);

  @override
  AppBuilderState createState() => new AppBuilderState();

  static AppBuilderState of(BuildContext context) {
    return context.ancestorStateOfType(const TypeMatcher<AppBuilderState>());
  }
}

class AppBuilderState extends State<AppBuilder> {

  @override
  Widget build(BuildContext context) {
    return widget.builder(context);
  }

  void rebuild() {
    setState(() {});
  }
}

class Home extends StatefulWidget {
  Home({Key key, this.title}) : super(key: key);


  final String title;

  @override
  _HomeState createState() => _HomeState();
}

class _HomeState extends State<Home> {

  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }
  final List<Widget> _children = [
    Recipes(),
    New(),
    PlaceholderWidget(Colors.green),
    Contact(),
    PlaceholderWidget(Colors.red)
  ];




  @override
  Widget build(BuildContext context) {
    return AppBuilder(builder: (context)
    {
      return Scaffold(
        appBar: AppBar(
          title: Text(widget.title),

        ),
        body: _children[currentIndex],
        bottomNavigationBar: BottomNavyBar(
          selectedIndex: currentIndex,
          showElevation: true,
          itemCornerRadius: 8,
          //iconSize: 30,
          curve: Curves.ease,
          onItemSelected: (index) =>
              setState(() {
                currentIndex = index;
              }),
          items: [
            BottomNavyBarItem(
              icon: Icon(Icons.apps),
              title: Text('Recettes'),
              activeColor: HexColor('#F88694'),
              textAlign: TextAlign.center,
            ),
            BottomNavyBarItem(
              icon: Icon(Icons.add),
              title: Text('Nouveau'),
              activeColor: HexColor('#95C7DD'),
              textAlign: TextAlign.center,

            ),
            BottomNavyBarItem(
              icon: Icon(Icons.swap_vert),
              title: Text('Importer'),
              activeColor: HexColor('#FEBB6D'),
              textAlign: TextAlign.center,

            ),
            BottomNavyBarItem(
              icon: Icon(Icons.info),
              title: Text('Contact'),
              activeColor: HexColor('#F88694'),
              textAlign: TextAlign.center,

            ),
            BottomNavyBarItem(
              icon: Icon(Icons.settings),
              title: Text('Paramètres'),
              activeColor: HexColor('#95C7DD'),
              textAlign: TextAlign.center,
            ),
          ],
        ),
      );
    });
  }
  void changeSelectedPage(int index) {
    setState(() {
      currentIndex = index;
    });
  }



}
class HexColor extends Color {
  static int _getColorFromHex(String hexColor) {
    hexColor = hexColor.toUpperCase().replaceAll("#", "");
    if (hexColor.length == 6) {
      hexColor = "FF" + hexColor;
    }
    return int.parse(hexColor, radix: 16);
  }

  HexColor(final String hexColor) : super(_getColorFromHex(hexColor));
}
  1. recipes.dart
import 'package:flutter/material.dart';
import 'package:nice_button/NiceButton.dart';

class Recipes extends StatefulWidget {

  Function changeSelectedPage;
  Recipes({Key key, this.changeSelectedPage}) : super(key: key);

  @override
  _RecipesState createState() => _RecipesState();

}

class _RecipesState extends State<Recipes> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(

    body: Material(
      child: Center(

    child: SizedBox(
        width: 350,
    child: Column(
        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
        children: <Widget>[

          Text.rich(
            TextSpan(
              children: <TextSpan>[
                TextSpan(text: 'Bienvenue sur l\'application', style: TextStyle(fontWeight: FontWeight.w900, fontSize: 35, fontFamily: 'Indies')),
                TextSpan(text: ' Gluci', style: TextStyle(color: HexColor('#F88694'),fontWeight: FontWeight.w900, fontSize: 35, fontFamily: 'Indies')),
                TextSpan(text: '\' ', style: TextStyle(color: HexColor('#95C7DD'), fontWeight: FontWeight.w900, fontSize: 35, fontFamily: 'Indies')),
                TextSpan(text: 'Aide', style: TextStyle(color: HexColor('#FEBB6D'), fontWeight: FontWeight.w900, fontSize: 35, fontFamily: 'Indies')),
                TextSpan(text: ' !', style: TextStyle(fontWeight: FontWeight.w900, fontSize: 35, fontFamily: 'Indies')),
              ],

            ),
            textAlign: TextAlign.center,


        ),



          Text(
            'Calculez les glucides d\' une recette pour la voir apparaitre ici. N\'hésitez pas à naviguer dans les onglets en bas pour découvrir les différentes fonctionnalités de notre nouvelle application !',
            textAlign: TextAlign.center,
            softWrap: true,
            style: TextStyle(
              fontSize: 15,

            ),

          ),
          NiceButton(
            // width: 515,
            elevation: 40,
            radius: 8.0,
            text: "Ajouter une recette",
            background: HexColor('#95C7DD'),
            onPressed: () {
              //widget.changeSelectedPage(2);
              setState(() {
                currentIndex = 1;
                AppBuilder.of(context).rebuild();
              });
            },
          ),
  ]
      ),
    ),
      ),
    ),
    );
  }

  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    throw UnimplementedError();
  }
} 

Thanks for everything.
rubidev68

1 Like

Okay, but this is not efficient. Are you sure you want to rebuild the whole app only for changing the menu? As the app gets more complicated, this operation is going to be expensive, plus possibly not a good user experience.

Thank you very much @sakina for your solution which I finally managed to implement and which is indeed much less consuming in system energy than the previous method!
Here is my final code:

  1. home.dart
import 'package:flutter/material.dart';
import 'package:bottom_navy_bar/bottom_navy_bar.dart';
import 'new.dart';
import 'placeholder.dart';
import 'contact.dart';

Map<int, Color> color =
{
  50:Color.fromRGBO(248,134,148, .1),
  100:Color.fromRGBO(248,134,148, .2),
  200:Color.fromRGBO(248,134,148, .3),
  300:Color.fromRGBO(248,134,148, .4),
  400:Color.fromRGBO(248,134,148, .5),
  500:Color.fromRGBO(248,134,148, .6),
  600:Color.fromRGBO(248,134,148, .7),
  700:Color.fromRGBO(248,134,148, .8),
  800:Color.fromRGBO(248,134,148, .9),
  900:Color.fromRGBO(248,134,148, 1),
};
int currentIndex = 0;

MaterialColor colorCustom = MaterialColor(0xFFF88694, color);



class Home extends StatefulWidget {
  Home({Key key, this.title}) : super(key: key);


  final String title;

  @override
  _HomeState createState() => _HomeState();
}

class _HomeState extends State<Home> {
  List<Widget> _children = [];

  @override
  void initState() {
    _children = [
      Recipes(changeSelectedPage),
      New(),
      PlaceholderWidget(Colors.green),
      Contact(),
      PlaceholderWidget(Colors.red)
    ];
  }

  void changeSelectedPage(int index) {
    setState(() {
      currentIndex = index;
    });
  }


  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }




  @override
  Widget build(BuildContext context) {
    return AppBuilder(builder: (context)
    {
      return Scaffold(
        appBar: AppBar(
          title: Text(widget.title),

        ),
        body: _children[currentIndex],
        bottomNavigationBar: BottomNavyBar(
          selectedIndex: currentIndex,
          showElevation: true,
          itemCornerRadius: 8,
          //iconSize: 30,
          curve: Curves.ease,
          onItemSelected: (index) =>
              setState(() {
                currentIndex = index;
              }),
          items: [
            BottomNavyBarItem(
              icon: Icon(Icons.apps),
              title: Text('Recettes'),
              activeColor: HexColor('#F88694'),
              textAlign: TextAlign.center,
            ),
            BottomNavyBarItem(
              icon: Icon(Icons.add),
              title: Text('Nouveau'),
              activeColor: HexColor('#95C7DD'),
              textAlign: TextAlign.center,

            ),
            BottomNavyBarItem(
              icon: Icon(Icons.swap_vert),
              title: Text('Importer'),
              activeColor: HexColor('#FEBB6D'),
              textAlign: TextAlign.center,

            ),
            BottomNavyBarItem(
              icon: Icon(Icons.info),
              title: Text('Contact'),
              activeColor: HexColor('#F88694'),
              textAlign: TextAlign.center,

            ),
            BottomNavyBarItem(
              icon: Icon(Icons.settings),
              title: Text('Paramètres'),
              activeColor: HexColor('#95C7DD'),
              textAlign: TextAlign.center,
            ),
          ],
        ),
      );
    });
  }



}
class HexColor extends Color {
  static int _getColorFromHex(String hexColor) {
    hexColor = hexColor.toUpperCase().replaceAll("#", "");
    if (hexColor.length == 6) {
      hexColor = "FF" + hexColor;
    }
    return int.parse(hexColor, radix: 16);
  }

  HexColor(final String hexColor) : super(_getColorFromHex(hexColor));
}
  1. recipes.dart
import 'package:flutter/material.dart';
import 'package:nice_button/NiceButton.dart';

class Recipes extends StatefulWidget {

  Function changeSelectedPage;
  Recipes(this.changeSelectedPage);

  @override
  _RecipesState createState() => _RecipesState();

}

class _RecipesState extends State<Recipes> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(

    body: Material(
      child: Center(

    child: SizedBox(
        width: 350,
    child: Column(
        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
        children: <Widget>[

          Text.rich(
            TextSpan(
              children: <TextSpan>[
                TextSpan(text: 'Bienvenue sur l\'application', style: TextStyle(fontWeight: FontWeight.w900, fontSize: 35, fontFamily: 'Indies')),
                TextSpan(text: ' Gluci', style: TextStyle(color: HexColor('#F88694'),fontWeight: FontWeight.w900, fontSize: 35, fontFamily: 'Indies')),
                TextSpan(text: '\' ', style: TextStyle(color: HexColor('#95C7DD'), fontWeight: FontWeight.w900, fontSize: 35, fontFamily: 'Indies')),
                TextSpan(text: 'Aide', style: TextStyle(color: HexColor('#FEBB6D'), fontWeight: FontWeight.w900, fontSize: 35, fontFamily: 'Indies')),
                TextSpan(text: ' !', style: TextStyle(fontWeight: FontWeight.w900, fontSize: 35, fontFamily: 'Indies')),
              ],

            ),
            textAlign: TextAlign.center,


        ),



          Text(
            'Calculez les glucides d\' une recette pour la voir apparaitre ici. N\'hésitez pas à naviguer dans les onglets en bas pour découvrir les différentes fonctionnalités de notre nouvelle application !',
            textAlign: TextAlign.center,
            softWrap: true,
            style: TextStyle(
              fontSize: 15,

            ),

          ),
          NiceButton(
            // width: 515,
            elevation: 40,
            radius: 8.0,
            text: "Ajouter une recette",
            background: HexColor('#95C7DD'),
            onPressed: () {
              //widget.changeSelectedPage(2);
              widget.changeSelectedPage(1);
            },
          ),
  ]
      ),
    ),
      ),
    ),
    );
  }

  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    throw UnimplementedError();
  }
}

Thank you very much
rubidev68

That’s great!! :smiley: