Home > OS >  The argument for the named parameters 'child' was already specified
The argument for the named parameters 'child' was already specified

Time:04-20

I'm getting an error here, but I don't understand why.

The argument for the named parameters 'child' was already specified

Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.blue,
      body: SafeArea(
  child: Container(
    child: Align(
      alignment: Alignment.topCenter,
      child: Text(
        'Welcome',
         style: TextStyle(
           fontSize: 20,
           fontWeight: FontWeight.bold,
         ),
        ),
      ),
    ),

   
    child: Padding(
      padding: const EdgeInsets.all(8.0),
      child: Lottie.network(
        'https://assets3.lottiefiles.com/packages/lf20_uavyvaxw.json')


    )
   )
);
}

CodePudding user response:

You cannot have two child parameters inside your Align() widget.

Display them into a Column() (or a Row(); as you like the most):

Align(
    alignment: Alignment.topCenter,
    child: Column(
      children: [
        const Text(
          'Welcome',
          style: TextStyle(
            fontSize: 20,
            fontWeight: FontWeight.bold,
          ),
        ),
        Padding(
            padding: const EdgeInsets.all(8.0),
            child: Lottie.network(
                'https://assets3.lottiefiles.com/packages/lf20_uavyvaxw.json'))
      ],
    ),
  )
  • Related