flutter控件之ListView滾動布局


ListView即滾動列表控件,能將子控件組成可滾動的列表。當你需要排列的子控件超出容器大小,就需要用到滾動塊。

import 'package:flutter/material.dart';
class ListDemo extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
   return new Scaffold(
     appBar: new AppBar(
       title: new Text("滾動布局"),
     ),
     body: new ListView(
       children: <Widget>[
         new Center(
           child: new Text(
             "Sweat",
             style: new TextStyle(
               fontFamily: "serif",
               fontSize: 26.0
             ),
           ),
         ),
         new Center(
           child: new Text(
             "huoyac honeybaby",
             style: new TextStyle(
               fontFamily: "serif",
               fontSize: 12.0
             ),
           ),
         ),
         new Center(
           child: new Text(
             '''
From fairest creatures we desire increase,
That thereby beauty's rose might never die,
But as the riper should by time decease,
His tender heir might bear his memory;
But thou, contracted to thine own bright eyes,
Feed'st thy light's flame with self-substantial fuel,
Making a famine where abundance lies,
Thyself thy foe, to thy sweet self too cruel.
Thout that are now the world's fresh ornament
And only herald to the gaudy spring,
Within thine own bud buriest thy content
And, tender churl, mak'st waste in niggarding.
Pity the world, or else this glutton be,
To eat the world's due, by the grave and thee.
WHEN forty winters shall besiege thy brow
And dig deep trenches in thy beauty's field,
Thy youth's proud livery, so gazed on now,
Will be a tottered weed of small worth held:
Then being asked where all thy beauty lies,
Where all the treasure of thy lusty days,
To say within thine own deep-sunken eyes
Were an all-eating shame and thriftless praise.
How much more prasie deserved thy beauty's use
If thou couldst answer, 'This fair child of mine
Shall sum my count and make my old excuse,'
Proving his beauty by succession thine.
This were to be new made when thou art old
And see thy blood warm when thou feel'st cold.
LOOK in thy glass, and tell the face thou viewest
Now is the time that face should form another,
Whose fresh repair if now thou renewest,
Thou dost beguile the world, unbless some mother.
For where is she so fair whose uneared womb
Disdains the tillage of thy husbandry?
Or who is he so fond will be the tomb
Of his self-love, to stop posterity?
Thou art thy mother's glass, and she in thee
Calls back the lovely April of her prime;
So thou through windows of thine age shalt see,
Despite of wrinkles, this thy golden time.
But if thou live rememb'red not to be,
Die single, and thine image dies with thee.
             ''',
             style: new TextStyle(
               fontFamily: "serif",
               fontSize: 14.0,
             ),
           ),
         )
       ],
     ),
   );
  }
}
void main(){
  runApp(new MaterialApp(
    title: "滾動布局",
    home: new ListDemo(),
  ));
}

效果:

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM