-1
class H extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
   child:   stack(context, 'assets/sbg.png', 80, 111, 58, 215, 'assets/logo.png', 'title', 'subtitle'),
    );
  }
}

//////////


 Widget stack(BuildContext context,image, left,top,height,width,logo,title,subtitle){
  return Stack(
          clipBehavior: Clip.none,
          children: [
            Positioned(
                left: createSize( left, context),
                top: createSize(top, context),
                height: createSize(height, context),
                width: createSize(width, context),
                child: Column(children: [
                   Image.asset(logo),
               Text(title,style: TextStyle(),),Text(subtitle),
                ],),
                
               ),
            Container(
              height: createSize(447, context),
              width: createSize(375, context),
              decoration: BoxDecoration(
                image: DecorationImage(
                    image: AssetImage(image), fit: BoxFit.cover),
              ),
            ),
          ],
        );
}

I have this issue on my flutter application. i am always getting an error like this "type 'double' is not a subtype of type 'int' in type cast" , what error i have made here? The following _TypeError was thrown building SignIn(dirty): type 'int' is not a subtype of type 'double'.

Abin Sunny
  • 89
  • 1
  • 7
  • Please update your post and show us the *LINE THE ERROR OCCURS ON*. ALSO: look [here](https://stackoverflow.com/a/53163726/421195) and [here](https://api.flutter.dev/flutter/dart-core/num/toDouble.html) – paulsm4 May 23 '21 at 20:25
  • You are right, I agree. But if you look at his code he uses his own functions to build widgets and he probably set the arguments to be of type `double` so he would have to write `.toDouble()` on every number he hardcodes into his function calls. That is very practical. So adding `.0` to every number or changing argument type to `int` would be a more logical solution in this case. Please reconsider the downvote. – Andrej May 23 '21 at 20:35

1 Answers1

1

To fix this error you could just add .0 to every number you have in your code. For example if you have 500 turn it into 500.0.

This happens because 500 is an int and 500.0 is a double and those are different types.

int is used to store whole numbers like: 500.

double is used to store numbers with decimal points: like: 1.618.

Andrej
  • 2,743
  • 2
  • 11
  • 28
  • If this answer helped you please consider clicking on the green checkmark to mark it as correct so it can help other people in the future. Have a nice day :) – Andrej May 23 '21 at 20:33
  • Okay. I did it. Thank you :) – Andrej May 23 '21 at 20:36