无法显示图标和文字

问题描述 投票:0回答:2

我似乎无法让图标按钮显示在其旁边。应该看起来像:

enter image description here

我正在关注Udacity中的入门教程。仍然试图让我了解所有正确的格式,小部件等

代码:

import 'package:flutter/material.dart';

void main() {
  runApp(
    MaterialApp(
      title: "Category List",
      home: Scaffold(
        appBar: AppBar(
          title: Text('This is a list item'),
        ),
        body: Category(),
      ),

    ),
  );
}

class Category extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Material(
      child: Container(
        child: Padding(
          padding: EdgeInsets.all(16.0),
          child: InkWell(
            onTap: () => {},
            child: Row(
              children: <Widget>[
                Icon(Icons.access_alarms),
                Text('Click'),
              ],     

            ),
          ),

        ),
      ),
    );
  }
}
flutter dart flutter-layout
2个回答
0
投票
import 'package:flutter/material.dart';

void main() {
  runApp(
    MaterialApp(
      title: "Category List",
      home: Scaffold(
        appBar: AppBar(
          title: Text('This is a list item'),
        ),
        body: Category(),
      ),

    ),
  );
}

class Category extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Material(
      child: Container(
        decoration:BoxDecoration(
          color:Colors.green.withOpacity(0.4),
          border:Border.all(),

        ),

        child: Padding(
          padding: EdgeInsets.all(16.0),
          child: InkWell(
            onTap: () => {},
            child: Row(
              children: <Widget>[
                Icon(Icons.access_alarms),
                Text('Click'),
              ],     

            ),
          ),

        ),
      ),
    );
  }
}

0
投票

您是否尝试过使用Expanded()小部件包装图标和文本?

© www.soinside.com 2019 - 2024. All rights reserved.