How to fix? error: The named parameter 'child' isn't defined. (undefined_named_parameter at [application_1]

Viewed 51

Excuse me, before I want to explain that this is the result of converting from figma using this So after I downloaded, I got an error in one of the codes

Before that, I used

Flutter (Channel stable, 2.10.3, on Microsoft Windows [Version 10.0.22572.201], locale en-US) Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)

import 'controller/splashscreen_controller.dart';
import 'package:application_1/core/app_export.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';

class SplashscreenScreen extends GetWidget<SplashscreenController> {
  @override
  Widget builder(BuildContext context) {
    return SafeArea(
      child: Scaffold(
        backgroundColor: ColorConstant.whiteA700,
        body: Container(
          width: size.width,
          child: SingleChildScrollView(
            child: Container(
              width: size.width,
              decoration: BoxDecoration(
                color: ColorConstant.whiteA700,
              ),
              child: Padding(
                padding: EdgeInsets.only(
                  left: getHorizontalSize(
                    11.56,
                  ),
                ),
                child: Text(
                  "lbl_skylink".tr,
                  overflow: TextOverflow.ellipsis,
                  textAlign: TextAlign.left,
                  style: AppStyle.textStylePoppinsmedium34.copyWith(
                    fontSize: getFontSize(
                      34,
                    ),
                  ),
                  child: Padding(
                    padding: EdgeInsets.only(
                      top: getVerticalSize(
                        7.22,
                      ),
                      bottom: getVerticalSize(
                        5.78,
                      ),
                    ),
                    child: Container(
                      height: getVerticalSize(
                        39.00,
                      ),
                      width: getHorizontalSize(
                        43.33,
                      ),
                      child: SvgPicture.asset(
                        ImageConstant.imgVector5,
                        fit: BoxFit.fill,
                        child: Padding(
                          padding: EdgeInsets.only(
                            top: getVerticalSize(
                              187.00,
                            ),
                            bottom: getVerticalSize(
                              0.01,
                            ),
                          ),
                          child: Container(
                            height: getVerticalSize(
                              192.99,
                            ),
                            width: getHorizontalSize(
                              375.00,
                            ),
                            child: SvgPicture.asset(
                              ImageConstant.imgBackgroundillu,
                              fit: BoxFit.fill,
                            ),
                          ),
                        ),
                      ),
                    ),
                  ),
                ),
              ),
            ),
          ),
        ),
      ),
    );
  }
}

For the build version I use on build.gradle

buildscript {
    ext.kotlin_version = '1.4.32'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:4.0.1'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}
1 Answers

The Error message is shown when you try to define child parameter to widgets that does not have "child" paramete, in this case SvgPicture.asset

But the main problem in your case is that it seems that the code you have downloaded is corrupted. It seems to have several fallacies.

Mainly widgets are wrongly nested and also are defining child parameters to widgets which does not have "child" parameters.

below is a code which I assumed your code was meant to be. Try it and see if it works.

import 'controller/splashscreen_controller.dart';
import 'package:application_1/core/app_export.dart';
import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';

class SplashscreenScreen extends GetWidget<SplashscreenController> {
  @override
  Widget builder(BuildContext context) {
    return SafeArea(
      child: Scaffold(
        backgroundColor: ColorConstant.whiteA700,
        body: Container(
          width: size.width,
          child: SingleChildScrollView(
            child: Container(
              width: size.width,
              decoration: BoxDecoration(
                color: ColorConstant.whiteA700,
              ),
              child: Column(
                children: [
                  Padding(
                    padding: EdgeInsets.only(
                      left: getHorizontalSize(
                        11.56,
                      ),
                    ),
                    child: Text(
                      "lbl_skylink".tr,
                      overflow: TextOverflow.ellipsis,
                      textAlign: TextAlign.left,
                      style: AppStyle.textStylePoppinsmedium34.copyWith(
                        fontSize: getFontSize(
                          34,
                        ),
                      ),
                    ),
                  ),
                  Padding(
                    padding: EdgeInsets.only(
                      top: getVerticalSize(
                        7.22,
                      ),
                      bottom: getVerticalSize(
                        5.78,
                      ),
                    ),
                    child: Container(
                      height: getVerticalSize(
                        39.00,
                      ),
                      width: getHorizontalSize(
                        43.33,
                      ),
                      child: SvgPicture.asset(
                        ImageConstant.imgVector5,
                        fit: BoxFit.fill,
                      ),
                    ),
                  ),
                  Padding(
                    padding: EdgeInsets.only(
                      top: getVerticalSize(
                        187.00,
                      ),
                      bottom: getVerticalSize(
                        0.01,
                      ),
                    ),
                    child: Container(
                      height: getVerticalSize(
                        192.99,
                      ),
                      width: getHorizontalSize(
                        375.00,
                      ),
                      child: SvgPicture.asset(
                        ImageConstant.imgBackgroundillu,
                        fit: BoxFit.fill,
                      ),
                    ),
                  ),
                ],
              ),
            ),
          ),
        ),
      ),
    );
  }
}

Related