成品直播原始碼,Flutter 夜間模式 全域性字型

zhibo系統開發發表於2023-03-03

成品直播原始碼,Flutter 夜間模式 全域性字型

import 'package:flutter/material.dart';
import 'package:flutter_widget/router/applicationRouterGradual.dart';
import 'package:flutter_widget/router/applicationRouterSlide.dart';
import 'package:flutter_widget/widget/layout.dart';
 
class HomeContent extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    // TODO: implement createState
    return _HomeContentState();
  }
}
 
class _HomeContentState extends State<HomeContent> {
  final List arrayRouter = [
    },
  ];
  bool modelDay = true;
  Brightness appBrightness = Brightness.light;
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return MaterialApp(
      title: 'Flutter 基礎學習',
      theme: ThemeData(
        // fontFamily: 'TianShi',//全域性字型設定
        brightness: appBrightness,
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        appBar: AppBar(
          title: Text("flutter 元件的學習"),
          actions: [
            Center(child: Text("主題切換")),
            Switch(
                activeColor: Colors.orange,
                value: modelDay,
                onChanged: (value) {
                  setState(() {  //切換主題
                    this.modelDay = value;
                    appBrightness =
                        this.modelDay ? Brightness.light : Brightness.dark;
                  });
                })
          ],
        ),
        body: SingleChildScrollView(
          child: Center(
            child: Column(
              children: arrayRouter
                  .map(
                    (item) => MaterialButton(
                      onPressed: () {
                        // Navigator.push(context,
                        //     MaterialPageRoute(builder: (context) => Layout()));
                        Navigator.pushNamed(context, item['router'],
                            arguments: {'desc': item['desc']});
                        //Navigator.push(context, ApplicationRouterGradual())
                        // Navigator.push(context,
                        //     ApplicationRouterGradual(widget: LessGroupPage()));
                        // Navigator.push(context, route)
                        // Navigator.push(context,
                        //     ApplicationRouterSlide(widget: LessGroupPage()));
                      },
                      color: Colors.cyan,
                      splashColor: Colors.green,
                      elevation: 10,
                      child: Text(
                        item['title'],
                        style: TextStyle(color: Colors.white),
                      ),
                    ),
                  )
                  .toList(),
            ),
          ),
        ),
      ),
    );
  }
}


以上就是成品直播原始碼,Flutter 夜間模式 全域性字型, 更多內容歡迎關注之後的文章


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

相關文章