import 'package:flutter/material.dart'。
void main() {
runApp(MyApp())。
}
class MyApp extends StatelessWidget{
@override
Widget build(BuildContext context) {
return MaterialApp(
標題。'Flutter Demo'。
主題。ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity。
),
主頁。MyHomePage(title: 'Flutter Demo Home Page') 。
);
}
}
class MyHomePage extends StatefulWidget{
MyHomePage({Key key, this.title}) : super(key: 密鑰)。
final String title。
@override
_MyHomePageState createState() => _MyHomePageState()。
}
class _MyHomePageState extends State< MyHomePage> {
FocusNode focusNode = FocusNode();
@override
void initState() {
super.initState()。
focusNode.addListener(() {
print('1: ${focusNode.hasFocus}') 。
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
標題。Text(widget.title),
),
body: _buildBody()。
);
}
小工具 _buildBody() {
return ListView.separagraph(
itemCount: 20,
SeparatorBuilder。(context, index) {
if ((index 1) % 4 == 0) {
return Container(
高度。100,
color: Colors.yellow,
孩子。Text('it is ads')。
);
} else {
return Container();
}
},
itemBuilder。(context, index) {
return Container(
高度。100。
color: Colors.blue,
孩子。Text('item index: $index')。)
);
},
);
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/315698.html
標籤:

