成品直播原始碼推薦,Flutter波浪進度條WaveProgressBar

zhibo系統開發發表於2023-09-25

成品直播原始碼推薦,Flutter波浪進度條WaveProgressBar

第一步:新增以下程式碼到你的pubspec.yaml檔案

dependencies:
  waveprogressbar_flutter: "^0.1.1"


第二步:導包,新增以下程式碼到你要使用的檔案下

import 'package:waveprogressbar_flutter/waveprogressbar_flutter.dart';


第三步:寫你的業務程式碼 


import 'package:flutter/material.dart';
import 'package:waveprogressbar_flutter/waveprogressbar_flutter.dart';
 
class BezierCurveDemo extends StatefulWidget{
  @override
  State<StatefulWidget> createState() {
    return BezierCurveDemoState();
  }
}
 
class BezierCurveDemoState extends State<BezierCurveDemo>{
 
  final TextEditingController _controller = new TextEditingController();
  //預設初始值為0.0
  double waterHeight=0.0;
  WaterController waterController=WaterController();
 
  @override
  void initState() {
    super.initState();
    WidgetsBinding widgetsBinding=WidgetsBinding.instance;
    widgetsBinding.addPostFrameCallback((callback){
      //這裡寫你想要顯示的百分比
      waterController.changeWaterHeight(0.82);
    });
  }
 
 
  @override
  Widget build(BuildContext context) {
 
    return new Scaffold(
      resizeToAvoidBottomPadding: false,
      appBar: new AppBar(
        title: new Text("貝塞爾曲線測試"),
      ),
      body: new Column(
        children: <Widget>[
          new Row(
            children: <Widget>[
              new Text("高度調整:    ",
                style: new TextStyle(fontSize: 20.0),
              ),
              new Container(
                width: 150.0,
                child: new TextField(
                    controller: _controller,
                    decoration: new InputDecoration(
                      hintText: "請輸入高度",
                    )
                ),
              ),
              new RaisedButton(onPressed: (){
                print("waterHeight is ${_controller.toString()}");
                FocusScope.of(context).requestFocus(FocusNode());
                waterController.changeWaterHeight(double.parse(_controller.text));
              },
                child: new Text("確定"),
              ),
            ],
          ),
          new Container(
            margin: EdgeInsets.only(top: 80.0),
            child: new Center(
              child: new WaveProgressBar(
                flowSpeed: 2.0,
                waveDistance:45.0,
                waterColor: Color(0xFF68BEFC),
                //strokeCircleColor: Color(0x50e16009),
                heightController: waterController,
                percentage: waterHeight,
                size: new Size (300,300),
                textStyle: new TextStyle(
                    color:Color(0x15000000),
                    fontSize: 60.0,
                    fontWeight: FontWeight.bold),
              ),
            ),
          ),
        ],
      ),
    );
  }
}


以上就是 成品直播原始碼推薦,Flutter波浪進度條WaveProgressBar,更多內容歡迎關注之後的文章


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/69978258/viewspace-2985694/,如需轉載,請註明出處,否則將追究法律責任。

相關文章