如何在颤动中为高架按钮提供圆角边框?

时间:2021-04-19 09:38:39

标签: flutter button flutter-layout

由于 RaisedButtonOutlineButton 已弃用,flutter 团队引入了新的 ElevatedButton。但我不知道如何使 ElevatedButton 的边框像下图一样圆润。

Rounded Border Button


ElevatedButton(
  onPressed: () {},
  child: Text('Testing'),
),

4 个答案:

答案 0 :(得分:1)

你可以这样做:

ElevatedButton(
  onPressed: () {},
  style: ElevatedButton.styleFrom(
    shape: new RoundedRectangleBorder(
      borderRadius: new BorderRadius.circular(30.0),
    ),
  ),
  child: Text(' Elevated Button')
)

答案 1 :(得分:0)

这是如何使用新的 Ele 按钮

ElevatedButtonThemeData(
      style: ButtonStyle(
        shape: MaterialStateProperty.resolveWith<OutlinedBorder>(
          (Set<MaterialState> states) {
            if (states.contains(MaterialState.disabled)) {
              return ContinuousRectangleBorder(borderRadius: BorderRadius.circular(10));
            }
            return ContinuousRectangleBorder(borderRadius: BorderRadius.circular(10)); //CHoose any shape you want
          },
        ),
        backgroundColor: MaterialStateProperty.resolveWith<Color>(
          (Set<MaterialState> states) {
            if (states.contains(MaterialState.disabled)) {
              return greyColor;
            }
            return selectedPrimaryColor; 
          },
        ),
        foregroundColor: MaterialStateProperty.resolveWith<Color>(
          (Set<MaterialState> states) {
            if (states.contains(MaterialState.disabled)) {
              return Colors.black;
            }
            return selectedPrimaryColor; 
          },
        ),
      ),
    ),

答案 2 :(得分:0)

library(dplyr)
library(tidyr)

df %>%
  separate_rows(categories, sep = ',') %>%
  count(id, categories, name = 'winner_count') %>%
  filter(categories != 'NA') %>%
  group_by(id) %>%
  slice_max(winner_count, n = 1, with_ties = FALSE) %>%
  ungroup %>%
  rename(winner = categories) %>%
  left_join(df, by = 'id') -> result

result

#    id winner      winner_count categories                                
#  <dbl> <chr>              <int> <chr>                                     
#1     1 apple                  1 apple,shoes/socks,trousers/jeans,chocolate
#2     2 apple                  2 apple,NA,apple,chocolate                  
#3     3 shoes/socks            1 shoes/socks,NA,NA,NA                      
#4     4 apple                  2 apple,apple,chocolate,chocolate     

答案 3 :(得分:0)

ElevatedButton(
  onPressed: () {},
  child: Text('Your Button')
  style: ElevatedButton.styleFrom(
    shape: StadiumBorder(),
  ),
)