Flutter nosuchmethoderror class string has no instance getter 'isnegative'

I am following a tutorial trying to create a horizontal SingleChildScrollView which contains object with product description and a currency + price tag with two decimals. Implementing NumberFormat.currency method returns an error: NoSuchMethodError class ‘String’ has no instance getter 'isNegative’

Can someone help to understand why it is not pulling “price” value please? If I hard code it and assign a value to the final double price = ie: 29.90; in AngeboteCard() class it does but not from the Angebote() class.

I tried replacing the value with: price, ‘$price’ but none of it works. It is always throwing an error as above.
It seems like the price value of the Angebote() doesn’t get delivered to the AngeboteCard() returning no value hence the error:

======== Exception caught by widgets library ======================================================= The following NoSuchMethodError was thrown building AngeboteCard(dirty, dependencies: [MediaQuery, _LocalizationsScope-[GlobalKey#ff95d], _InheritedTheme]): Class ‘String’ has no instance getter ‘isNegative’. Receiver: “null” Tried calling: isNegative

The relevant error-causing widget was: AngeboteCard file:///Users/nebojsa.kuzmanovic/Development/FlutterProjects/hotz/lib/screens/home/components/angebote.dart:29:11 When the exception was thrown, this was the stack: #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5) #1 NumberFormat._signPrefix (package:intl/src/intl/number_format.dart:786:30) #2 NumberFormat.format (package:intl/src/intl/number_format.dart:430:10) #3 AngeboteCard.build (package:hotz/screens/home/components/angebote.dart:107:80) #4 StatelessElement.build (package:flutter/src/widgets/framework.dart:4569:28) …

The code:

import 'package:flutter/material.dart';
import 'package:hotz/constants.dart';
import 'package:intl/intl.dart';
import 'package:intl/number_symbols.dart';

class Angebote extends StatelessWidget {
  const Angebote({
    Key key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return SingleChildScrollView(
      scrollDirection: Axis.horizontal,
      child: Row(
        children: <Widget>[
          AngeboteCard(
            image: "assets/images/pork_belly.png",
            product: "Schweinsbrust frisch",
            price: 29.90,
            press: () {},
          ),
        ],
      ),
    );
  }
}

class AngeboteCard extends StatelessWidget {
  const AngeboteCard({
    Key key,
    this.image,
    this.title,
    this.product,
    this.price,
    this.press,
  }) : super(key: key);
  final String image, title, product;
  final double price;
  final Function press;

  @override
  Widget build(BuildContext context) {
    Size size = MediaQuery.of(context).size;
    return GestureDetector(
      onTap: press,
      child: Container(
        margin: EdgeInsets.only(
          left: kDefaultPadding,
          top: kDefaultPadding / 2,
          bottom: kDefaultPadding / 0.5,
          right: kDefaultPadding,
        ),
        width: size.width * 0.8,
        height: 300,
        child: Column(
          children: <Widget>[
            Image.asset(image),
            GestureDetector(
              onTap: press,
              child: Container(
                padding: EdgeInsets.all(kDefaultPadding / 2),
                decoration: BoxDecoration(
                  color: Colors.white,
                  borderRadius: BorderRadius.only(
                    bottomLeft: Radius.circular(10),
                    bottomRight: Radius.circular(10),
                  ),
                  boxShadow: [
                    BoxShadow(
                      offset: Offset(0, 10),
                      blurRadius: 50,
                      color: kPrimaryColour.withOpacity(0.23),
                    ),
                  ],
                ),
                child: Row(
                  children: <Widget>[
                    RichText(
                      text: TextSpan(
                        children: [
                          TextSpan(
                              text: "$title\n".toUpperCase(),
                              style: Theme.of(context).textTheme.button),
                          TextSpan(
                            text: "$product\n".toUpperCase(),
                            style: TextStyle(
                                color: kPrimaryColour.withOpacity(0.5)),
                          ),
                        ],
                      ),
                    ),
                    Spacer(),
                    Text(
                    NumberFormat.currency(locale: 'de_CH', decimalDigits: 2).format('$price'),
                      style: Theme.of(context)
                          .textTheme
                          .button
                          .copyWith(color: kPrimaryColour),
                    )
                  ],
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }
}  ```

Class ‘String’ has no instance getter ‘isNegative’. Receiver: “null” Tried calling: isNegative
When the exception was thrown, this was the stack:
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5)
#1 NumberFormat._signPrefix (package:intl/src/intl/number_format.dart:786:30)
#2 NumberFormat.format (package:intl/src/intl/number_format.dart:430:10)
#3 AngeboteCard.build

:thinking: let’s check that format method

String format(
    dynamic number
)

Format number according to our pattern and return the formatted string.

error refers to a prop. isNegative, let’s check that too …

num class

isNegative property
Whether if the number is negative.

I think you are providing a string to .format() when the method is expecting a number; so I’d try without interpolation, i.e.

NumberFormat.currency(locale: 'de_CH', decimalDigits: 2).format(price),

Hth.