flutter - 如何在按钮的右上角显示可点击的图标?

标签 flutter dart

我正在尝试在按钮的右上角获得一个可单击的图标。我尝试将FloatingActionButton添加到行小部件,但只是将其添加到按钮的右侧。我希望它 float 在右上角的按钮上。任何帮助,将不胜感激。我有一个截图,现在看起来如下。

            ButtonTheme (
              minWidth: 250.0,
              height: 80.0,
              buttonColor: Color.fromRGBO(234, 135, 137, 1.0),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.center,
                crossAxisAlignment: CrossAxisAlignment.start,
                children: <Widget>[
                  RaisedButton (
                    shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(10.0),
                      side: BorderSide(
                        color: Colors.transparent,
                      ),
                    ),
                    child: Text(
                      'Daily Challenge',
                      style: TextStyle(
                        color: Colors.white,
                        fontSize: 22.0,
                        fontFamily: 'MuseoSans',
                      ),
                    ),
                    onPressed: () {
                      Navigator.push(
                        context,
                        MaterialPageRoute(builder: (context) => DailyMedChallenge(uid: user.uid, qidDC: user.qidDC)),
                      );
                    },
                  ),
                  Container(
                    width: 35.0,
                    height: 35.0,
                    child: FloatingActionButton(
                      child: Icon(
                        Icons.help,
                      ),
                      backgroundColor: Colors.grey,
                      onPressed: () {

                      },
                    ),
                  )
                ],
              ),
            ),

how it looks now

最佳答案

您可以使用“堆栈和定位”小部件


   ButtonTheme (
              minWidth: 250.0,
              height: 80.0,
              buttonColor: Color.fromRGBO(234, 135, 137, 1.0),
              child: Stack(
                 children: [
                  RaisedButton (
                    shape: RoundedRectangleBorder(
                      borderRadius: BorderRadius.circular(10.0),
                      side: BorderSide(
                        color: Colors.transparent,
                      ),
                    ),
                    child: Text(
                      'Daily Challenge',
                      style: TextStyle(
                        color: Colors.white,
                        fontSize: 22.0,
                        fontFamily: 'MuseoSans',
                      ),
                    ),
                    onPressed: () {
                      Navigator.push(
                        context,
                        MaterialPageRoute(builder: (context) => DailyMedChallenge(uid: user.uid, qidDC: user.qidDC)),
                      );
                    },
                  ),
                  Positioned( // will be positioned in the top right of the container
                    top: 0,
                    right: 0,
                    child Icon(
                        Icons.help,
                      ),
                   )
                ]
              )
            ),


关于flutter - 如何在按钮的右上角显示可点击的图标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60533344/

相关文章:

visual-studio-code - 处理异常 : Process "C:\Users\...\android\gradlew.bat" exited abnormally:

flutter - dart 中的日期时间比较

flutter - 如何在 Flutter web 中使用 .env?

dart - Flutter Positioned Transitioned to below other Stack child - 如何获得高度?

firebase - Firestore : Updating field in an object removes previous field

flutter - 分段条滚动条问题

ios - 未找到 Flutter shared_preferences 模块 - iOS Xcode 构建

android-studio - Flutter doctor 错误 - 找不到 Android sdkmanager 工具。 window

html - 如何使用 Dart :html library to write html files?

flutter - Flutter BlendMode 'the getter isn' t定义'