//代码块 importM import 'package:flutter/material.dart'; void main() { runApp( MaterialApp(theme: ThemeData( primarySwatch: Colors.yellow //导航栏颜色 ),
home: Scaffold( appBar: AppBar(title: const Text("这是导航栏", textDirection: TextDirection.rtl)), body: const MyApp() )) ); } //在Flutter中自定义组件其实就是一个类,这个类需要继承StatelessWidget/StatefulWidget //代码块 statelessW class MyApp extends StatelessWidget{ const MyApp({super.key}); @override Widget build(BuildContext context) { // TODO: implement build return const Center( child: Text( "你好flutter 我是一个自定义的主键", textDirection: TextDirection.ltr, style: TextStyle( // color: Colors.red color: Color.fromRGBO(190, 190, 34, 1), fontSize: 40.0), ), ); } }
标签:const,自定义,TextDirection,MyApp,抽离成,组件,Flutter From: https://www.cnblogs.com/xbinbin/p/17800699.html