When I'm trying to input text into the flutter app, I'm not able to move to the next screen and get this error. I've even looked at some other solutions to similar questions asked earlier but it's not working for me. Following is the code for the buttonbartheme class that is throwing the error.

class ButtonBarTheme extends InheritedWidget {

  /// Constructs a button bar theme that configures all descendent [ButtonBar]
  /// widgets.
  ///
  /// The [data] must not be null.

  const ButtonBarTheme({
    Key? key,
    required this.data,
    required Widget child,
  })  : assert(data != null), <- ERROR
        super(key: key, child: child);
  final ButtonBarThemeData data; 

  /// Returns the configuration [data] from the closest [ButtonBarTheme]
  /// ancestor. If there is no ancestor, it returns [ThemeData.buttonBarTheme].
  /// Applications can assume that the returned value will not be null.
  ///
  /// Typical usage is as follows:
  ///
  /// ```dart
  /// ButtonBarThemeData theme = ButtonBarTheme.of(context);
  /// ```

  static ButtonBarThemeData of(BuildContext context) {
    final ButtonBarTheme? buttonBarTheme =
        context.dependOnInheritedWidgetOfExactType<ButtonBarTheme>();
    return buttonBarTheme?.data ?? Theme.of(context).buttonBarTheme;
  }

I am using Buttonbartheme in the dashboard and other screens as follows:

ButtonBarTheme(
              // makes buttons use the appropriate styles for cards
              data: null,
              child: ButtonBar(
                children: <Widget>[
                  TextButton(
                    child: const Text('Share'),
                    onPressed: () {
                      // ignore: todo
                      //TODO Implement share to social media
                    },
                  ),
                  TextButton(
                    child: const Text('Dismiss'),
                    onPressed: () {
                      client.show1 = false;
                      update(client);
                    },
                  ),
                ],
              ),
            ),
1

There are 1 answers

1
belinda.g.freitas On

Do:

ButtonBarTheme(
   data: ButtonBarThemeData(),
   child: //rest of code
)