Home > Net >  why child key word in not working in flowing dart code?
why child key word in not working in flowing dart code?

Time:01-28

void showNearbyRidersAlert(BuildContext context) {
  showDialog(
    context: context,
     **child**: AlertDialog(
      shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.all(Radius.circular(10.0))),
      title: Text(
        'Congratulations!',
        style: isThemeCurrentlyDark(context)
            ? TitleStyles.white
            : TitleStyles.black,
      ),
      content: Text(
        'There are enough Riders in your area. Drivers can now see your hotspot and come to pick you up.',
        style:
            isThemeCurrentlyDark(context) ? BodyStyles.white : BodyStyles.black,
      ),
      actions: <Widget>[
        RaisedButton(
          child: Text('Okay'),
          color: invertColorsTheme(context),
          textColor: invertInvertColorsStrong(context),
          elevation: 3.0,
          shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.all(Radius.circular(5.0))),
          onPressed: () {
            Navigator.pop(context);
          },
        ),
      ],
    ),
  );
}

error show in the 4th line on child keyword.

CodePudding user response:

showDialog don't have child property, use builder.

Reference : https://api.flutter.dev/flutter/material/showDialog.html

example :

  void showNearbyRidersAlert(BuildContext context) {
    showDialog(
        context: context,
        builder: (context) {
          return AlertDialog(
              shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(10.0))),
              title: Text(
                'Congratulations!',
                style: isThemeCurrentlyDark(context) ? TitleStyles.white : TitleStyles.black,
              ),
              content: Text(
                'There are enough Riders in your area. Drivers can now see your hotspot and come to pick you up.',
                style: isThemeCurrentlyDark(context) ? BodyStyles.white : BodyStyles.black,
              ),
              actions: <Widget>[
                RaisedButton(
                  child: Text('Okay'),
                  color: invertColorsTheme(context),
                  textColor: invertInvertColorsStrong(context),
                  elevation: 3.0,
                  shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(5.0))),
                  onPressed: () {
                    Navigator.pop(context);
                  },
                ),
              ]);
        });
  }
  •  Tags:  
  • Related