[英]Create Flutter button menu
您可以使用percent_indicator
來獲得類似的結果。
在你的pubspec.yml
dependencies:
percent_indicator: "^1.0.16"
菜單項的小部件如下:
new CircularPercentIndicator(
radius: 60.0,
lineWidth: 5.0,
percent: 1.0,
center: ...,// put the center of circle (image or what you want)
progressColor: Colors.green,
)
為了能夠控制按鈕的分布,您可能需要使用一列行。
Column(
children: [
Row(
... // your first line set of buttons
),
Row(
... // your second line set of buttons
),
Row(
... // your third line set of buttons
),
],
)
使用MainAxisAlignment
屬性來處理行或列中元素的定位。
一個完整的例子:
import 'package:flutter/material.dart';
import 'package:percent_indicator/percent_indicator.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'my solo learn',
home: Scaffold(
appBar: AppBar(
title: Text('my solo learn'),
),
body: Column(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
CircularPercentIndicator(
radius: 60.0,
lineWidth: 5.0,
percent: 1.0,
center: Text('lesson1'),
progressColor: Colors.green,
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
CircularPercentIndicator(
radius: 60.0,
lineWidth: 5.0,
percent: 0.0,
center: Text('lesson2'),
progressColor: Colors.green,
),
CircularPercentIndicator(
radius: 60.0,
lineWidth: 5.0,
percent: 0.8,
center: Text('lesson3'),
progressColor: Colors.green,
),
],
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
CircularPercentIndicator(
radius: 60.0,
lineWidth: 5.0,
percent: 0.6,
center: Text('lesson4'),
progressColor: Colors.green,
),
],
),
],
)
),
);
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.