type 'Color' is not a subtype of type 'ImageProvider<dynamic>'

1

I am trying out the new XD to flutter plugin. I have tried to export part of the tutorial app, which should be very basic. It results in me just having a single .dart file that should take care of displaying four images and a bit of text. However, I keep getting the following error and cannot work out where it is coming from. Here is the full code:

import 'package:flutter/material.dart';
import 'dart:ui' as ui;
import 'package:flutter_svg/flutter_svg.dart';
//import './Monstera03.dart';
//import './RubberPlant.dart';
import 'package:adobe_xd/specific_rect_clip.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: const Color(0xfff8f8f8),
      body: Stack(
        children: <Widget>[
          Transform.translate(
            offset: Offset(-390.5, 31.68),
            child:
            // Adobe XD layer: 'Background texture' (group)
            SvgPicture.string(
              _shapeSVG_22fb7be636734da69d731b3da028d2d8,
              allowDrawingOutsideViewBox: true,
            ),
          ),
          // Adobe XD layer: 'Background texture' (group)
          Stack(
            children: <Widget>[
              Container(
                width: 375.0,
                height: 1275.0,
                decoration: BoxDecoration(
                  color: const Color(0xffffffff),
                  border:
                  Border.all(width: 1.0, color: const Color(0xff707070)),
                ),
              ),
            ],
          ),
          Transform.translate(
            offset: Offset(44.0, 108.0),
            child:
            // Adobe XD layer: 'Browse Plants Repea…' (none)
            SpecificRectClip(
              rect: Rect.fromLTWH(0, 0, 288, 1078),
              child: UnconstrainedBox(
                alignment: Alignment.topLeft,
                child: Container(
                  width: 288,
                  height: 1121,
                  child: GridView.count(
                    primary: false,
                    padding: EdgeInsets.all(0),
                    mainAxisSpacing: 31,
                    crossAxisSpacing: 20,
                    crossAxisCount: 1,
                    childAspectRatio: 1.1206225680933852,
                    children: [
                      {
                        'fill': const Color(0xff3131a1),
                        'text': 'Monstera',
                      },
                      {
                        'fill': const Color(0xff3131a1),
                        'text': 'Rubber Plant',
                      },
                      {
                        'fill': const Color(0xff3131a1),
                        'text': 'Rubber Plant',
                      },
                      {
                        'fill': const Color(0xff3131a1),
                        'text': 'Rubber Plant',
                      },
                    ].map((map) {
                      final fill = map['fill'];
                      final text = map['text'];
                      return Transform.translate(
                        offset: Offset(-44.0, -127.0),
                        child: Stack(
                          children: <Widget>[
                            Transform.translate(
                              offset: Offset(88.0, 127.0),
                              child:
                              // Adobe XD layer: 'monstera_m' (shape)
                              Container(
                                width: 204.0,
                                height: 204.0,
                                decoration: BoxDecoration(
                                  borderRadius: BorderRadius.all(
                                      Radius.elliptical(102.0, 102.0)),
                                  image: DecorationImage(
                                    image: fill,
                                    fit: BoxFit.cover,
                                  ),
                                ),
                              ),
                            ),
                            Transform.translate(
                              offset: Offset(44.0, 344.0),
                              child: SizedBox(
                                width: 288.0,
                                height: 28.0,
                                child: SingleChildScrollView(
                                    child: Text(
                                      text,
                                      style: TextStyle(
                                        fontFamily: 'Adobe Garamond Pro',
                                        fontSize: 29,
                                        color: const Color(0xff3131a1),
                                        fontStyle: FontStyle.italic,
                                        fontWeight: FontWeight.w700,
                                        height: 1.6551724137931034,
                                      ),
                                      textAlign: TextAlign.center,
                                    )),
                              ),
                            ),
                          ],
                        ),
                      );
                    }).toList(),
                  ),
                ),
              ),
            ),
          ),
          // Adobe XD layer: 'Browse Plants Header' (group)
          Stack(
            children: <Widget>[
              // Adobe XD layer: 'Background' (shape)
              ClipRect(
                child: BackdropFilter(
                  filter: ui.ImageFilter.blur(sigmaX: 30.0, sigmaY: 30.0),
                  child: Container(
                    width: 375.0,
                    height: 72.0,
                    decoration: BoxDecoration(
                      color: const Color(0x00ffffff),
                    ),
                  ),
                ),
              ),
              Transform.translate(
                offset: Offset(94.55, 25.0),
                child: SizedBox(
                  width: 186.0,
                  child: Text(
                    'BROWSE PLANTS',
                    style: TextStyle(
                      fontFamily: 'Fira Sans',
                      fontSize: 20,
                      color: const Color(0xff3131a1),
                      letterSpacing: 0.4,
                      fontWeight: FontWeight.w600,
                    ),
                    textAlign: TextAlign.center,
                  ),
                ),
              ),
              Transform.translate(
                offset: Offset(24.0, 24.0),
                child:
                // Adobe XD layer: 'Exit' (group)
                SvgPicture.string(
                  _shapeSVG_32c13fef011a49b7a2545e2aaeb6231c,
                  allowDrawingOutsideViewBox: true,
                ),
              ),
              Transform.translate(
                offset: Offset(327.0, 24.0),
                child:
                // Adobe XD layer: 'Exit' (group)
                Stack(
                  children: <Widget>[
                    Transform.translate(
                      offset: Offset(3.63, 3.63),
                      child:
                      // Adobe XD layer: 'Exit' (group)
                      Stack(
                        children: <Widget>[],
                      ),
                    ),
                  ],
                ),
              ),
              Transform.translate(
                offset: Offset(0.0, -5.0),
                child:
                // Adobe XD layer: 'Back Arrow' (group)
                Stack(
                  children: <Widget>[
                    Transform.translate(
                      offset: Offset(24.0, 29.0),
                      child: Container(
                        width: 24.0,
                        height: 24.0,
                        decoration: BoxDecoration(
                          border: Border.all(
                              width: 1.0, color: const Color(0xffffffff)),
                        ),
                      ),
                    ),
                  ],
                ),
              ),
            ],
          ),
        ],
      ),
    );
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        // This is the theme of your application.
        //
        // Try running your application with "flutter run". You'll see the
        // application has a blue toolbar. Then, without quitting the app, try
        // changing the primarySwatch below to Colors.green and then invoke
        // "hot reload" (press "r" in the console where you ran "flutter run",
        // or simply save your changes to "hot reload" in a Flutter IDE).
        // Notice that the counter didn't reset back to zero; the application
        // is not restarted.
        primarySwatch: Colors.blue,
        // This makes the visual density adapt to the platform that you run
        // the app on. For desktop platforms, the controls will be smaller and
        // closer together (more dense) than on mobile platforms.
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  // This widget is the home page of your application. It is stateful, meaning
  // that it has a State object (defined below) that contains fields that affect
  // how it looks.

  // This class is the configuration for the state. It holds the values (in this
  // case the title) provided by the parent (in this case the App widget) and
  // used by the build method of the State. Fields in a Widget subclass are
  // always marked "final".

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      // This call to setState tells the Flutter framework that something has
      // changed in this State, which causes it to rerun the build method below
      // so that the display can reflect the updated values. If we changed
      // _counter without calling setState(), then the build method would not be
      // called again, and so nothing would appear to happen.
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    // This method is rerun every time setState is called, for instance as done
    // by the _incrementCounter method above.
    //
    // The Flutter framework has been optimized to make rerunning build methods
    // fast, so that you can just rebuild anything that needs updating rather
    // than having to individually change instances of widgets.
    return Scaffold(
      appBar: AppBar(
        // Here we take the value from the MyHomePage object that was created by
        // the App.build method, and use it to set our appbar title.
        title: Text(widget.title),
      ),
      body: Center(
        // Center is a layout widget. It takes a single child and positions it
        // in the middle of the parent.
        child: Column(
          // Column is also a layout widget. It takes a list of children and
          // arranges them vertically. By default, it sizes itself to fit its
          // children horizontally, and tries to be as tall as its parent.
          //
          // Invoke "debug painting" (press "p" in the console, choose the
          // "Toggle Debug Paint" action from the Flutter Inspector in Android
          // Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
          // to see the wireframe for each widget.
          //
          // Column has various properties to control how it sizes itself and
          // how it positions its children. Here we use mainAxisAlignment to
          // center the children vertically; the main axis here is the vertical
          // axis because Columns are vertical (the cross axis would be
          // horizontal).
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headline4,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}

const String _shapeSVG_22fb7be636734da69d731b3da028d2d8 = 'omitted due to length';
const String _shapeSVG_32c13fef011a49b7a2545e2aaeb6231c = 'omitted due to length';

Does anyone know what might be causing this?

flutter
dart
asked on Stack Overflow May 19, 2020 by CJW

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0