0

For some reason when I export my Adobe XD project to flutter using XD to flutter plugin

it gives the error

The parameter 'key' can't have a value of 'null' because of its type, but the implicit default value is 'null'.
Try adding either an explicit non-'null' default value or the 'required' modifier.

it's a new project, every time I export's it, give that error

it's very simple code just text widget in the middle of the screen code :

    import 'package:flutter/material.dart';
    import 'package:adobe_xd/pinned.dart';
    
    class XDIPhone678SE1 extends StatelessWidget {
      
      XDIPhone678SE1(
        {
        Key key,
      }) : super(key: key);
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          backgroundColor: const Color(0xffffffff),
          body: Stack(
            children: <Widget>[
              Pinned.fromPins(
                Pin(size: 143.0, middle: 0.5),
                Pin(size: 27.0, middle: 0.5),
            

    child: Text(
              'Hello World!',
              style: TextStyle(
                fontFamily: 'Segoe UI',
                fontSize: 20,
                color: const Color(0xff707070),
              ),
              textAlign: TextAlign.left,
            ),
          ),
        ],
      )
  }
}
,
    );

in the // pubspec.yaml

dependencies:
 adobe_xd: ^2.0.0
  flutter:
    sdk: flutter
RTXGamer
  • 3,215
  • 6
  • 20
  • 29
winpriv
  • 21
  • 4

1 Answers1

1

Your parameter key in

XDIPhone678SE1({
  Key key,
}) : super(key: key);

is a non-nullable type Key but you didn't specify it as required. It means your class could be constructed like that:

XDIPhone678SE1();

which should be fine since the parameter key is not required, but then you end up with your key being null...

You have 2 ways to fix it:

  1. Change your type to Key? so key can be null
  2. Make key a required parameter:
XDIPhone678SE1({
  required Key key,
}) : super(key: key);
Valentin Vignal
  • 6,151
  • 2
  • 33
  • 73