SVG仅在热重载后显示

时间:2019-09-01 11:26:41

标签: flutter

首次启动应用程序时未加载SVG。仅在热重载后显示。我正在使用Flutter SVG库。我在有状态的小部件内包含SVG。代码有什么问题?我还添加了屏幕截图。看看!

之前:

enter image description here

之后:

enter image description here


class FirstPage extends StatefulWidget {
  _FirstPageState createState() => _FirstPageState();
}

class _FirstPageState extends State<FirstPage> {
  int height = 180;

  Color maleCardColor = inactiveCardColor;
  Color femaleCardColor = inactiveCardColor;

  Gender selectedGender;

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Padding(
        padding: const EdgeInsets.fromLTRB(8.0, 30, 8.0, 0.0),
        child: Column(
          children: <Widget>[
            appTitle(),
            SizedBox(
              height: 15.0,
            ),
            Row(
              children: <Widget>[
                GestureDetector(
                  child: ReusableCard(
                    color: selectedGender == Gender.female
                        ? activeCardColor
                        : inactiveCardColor,
                    cardChild: Column(
                      children: <Widget>[
                        SvgPicture.asset(
                          'assets/female.svg',
                          color: Colors.white,
                        ),
                        SizedBox(
                          height: 15.0,
                        ),
                        Text(
                          'FEMALE',
                          style: kCardDefaultText,
                        ),
                      ],
                    ),
                  ),
                  onTap: () {
                    setState(() {
                      selectedGender = Gender.female;
                    });
                  },
                ),

0 个答案:

没有答案