本來想要做個(gè)這樣的,

創(chuàng)新互聯(lián)專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于成都網(wǎng)站設(shè)計(jì)、網(wǎng)站制作、東山網(wǎng)絡(luò)推廣、小程序制作、東山網(wǎng)絡(luò)營銷、東山企業(yè)策劃、東山品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運(yùn)營等,從售前售中售后,我們都將竭誠為您服務(wù),您的肯定,是我們最大的嘉獎(jiǎng);創(chuàng)新互聯(lián)為所有大學(xué)生創(chuàng)業(yè)者提供東山建站搭建服務(wù),24小時(shí)服務(wù)熱線:18980820575,官方網(wǎng)址:chinadenli.net
結(jié)果處理PageView的時(shí)候就如上圖了,以前用Swift開發(fā)這樣的Page控件的時(shí)候用的UIScrollView,有滾動(dòng)寬度或者高度的設(shè)置,所以看到width的時(shí)候我是比較興奮地去查找相關(guān)的width屬性,當(dāng)然結(jié)果就是沒有,單獨(dú)把PageView部件抽出是沒有問題的,但是會是最大高度,好了,問題找到了,高度沒有限制好導(dǎo)致PageView無法限制自身的高度,我是在SafeArea中添加的列部件,列中添加行部件,原來是PageView作為列部件的children之一,現(xiàn)在要限制列部件除上面的兩行外設(shè)置PageView高度最大化,我把PageView放在Expanded中,Expanded作為列部件的children之一,好了問題解決了
Column(
children:[
Widget1,
Widget2,
AspectRatio(aspectRatio: ../..,child:PageView(....))
])
如整個(gè)場景全部是分頁,則去除Column,改為PageView(),全部重新構(gòu)建場景,Expanded需要在確定的部件需要足夠多的高度或者寬度時(shí)使用,
泰戈?duì)栵w鳥集精選(英文版) txt全集小說附件已上傳到百度網(wǎng)盤,點(diǎn)擊免費(fèi)下載:
內(nèi)容預(yù)覽:
泰戈?duì)栵w鳥集精選(英文版)
1
Stray birds of summer come to my window to sing and fly away.
And yellow leaves of autumn, which have no songs, flutter and fall there with a sign.
2
O Troupe of little vagrants of the world, leave your footprints in my words.
3
The world puts off its mask of vastness to its lover.
It becomes small as one song, as one kiss of the eternal.
4
It is the tears of the earth that keep here smiles in bloom.
5
The mighty desert is burning for the love of a bladeof grass who shakes her head and laughs and flies away.
6
If you shed tears when you miss the sun, you also miss the stars.
7
The sands in your way beg for your song and your movement, dancing water. Will you carry the burden of their lameness?
8
Her wishful face haunts my dreams like the rain at night.
9
Once we dreamt that we were strangers.
We wake up to find that we were dear to each other.
10
Sorrow is hushed into peace in my heart like the evening among the silent trees.
11
Some unseen fingers, like an idle breeze, are playing upon my heart the music of the ripples.
12
What language is thine, O sea?
The language of eternal question.……
有問題再找我
在上一篇文章中我們了解到Stream及響應(yīng)式編程的相關(guān)概念,本文著重介紹在引入 RxDart 三方庫后,不同Subject在實(shí)際開發(fā)中的應(yīng)用場景。
先附上演示項(xiàng)目代碼: flutter_movie
RxDart 是基于 ReactiveX 標(biāo)準(zhǔn)API的Dart版本實(shí)現(xiàn),由Dart標(biāo)準(zhǔn)庫中Stream擴(kuò)展而成。因此,RxDart與Dart的相關(guān)術(shù)語稍有區(qū)別:
Observable 等同于 Stream , Subject 等同于 StreamController ,前者均由后者繼承而來。
不同于Dart,RxDart提供了三種StreamController的變體來應(yīng)用到不同的場景:
PublishSubject是最普通的廣播StreamController,和StreamController唯一的區(qū)別是它返回對象是Observable,而StreamController返回的是Stream。
PublishSubject PublishSubject
從圖中可以了解到,listener只能監(jiān)聽到訂閱之后的事件。
示例代碼:
BehaviorSubject也是廣播StreamController,和PublishSubject的區(qū)別是它會額外返回訂閱前的最后一次事件。
BehaviorSubject BehaviorSubject
示例代碼:
ReplaySubject也是廣播StreamController,從字面上可以了解到它可以回放已經(jīng)消失的事件。
ReplaySubject ReplaySubject
示例代碼:
上文提到 StreamBuilder 作為Flutter中根據(jù)Stream生成Widget的便利工具,這里結(jié)合Subject來一起使用。
tab_bar.dart - 01 tab_bar.dart - 01 tab_bar.dart - 02 tab_bar.dart - 02
以上代碼實(shí)現(xiàn)了一個(gè)簡單的TabBar(或Segment),該Widget被定義成為一個(gè)StatefulWidget(因?yàn)樗邳c(diǎn)擊交互后有更新高亮索引的需求)。
在 build 函數(shù)內(nèi)部我們就使用了StreamBuilder來構(gòu)建UI,它監(jiān)聽的數(shù)據(jù)源為BLoc的 tabList ,在builder閉包內(nèi)部才是實(shí)際的UI構(gòu)建代碼。
tab_bloc.dart tab_bloc.dart
至于 tab_bloc.dart 則更加簡單,他從構(gòu)造函數(shù)接收一個(gè)字符串類型的List,然后使用ReplaySubject包裝數(shù)據(jù),
同時(shí)暴露出stream類型的對象 tabList 供外部訂閱(即 tab_bar.dart 中第44行代碼中的stream)。
最后,我們來看看完整的調(diào)用流程。
main.dart main.dart
在 main.dart 第30~50行代碼中,我們使用了 BlocProvider 來管理bloc(對于BlocProvider深入了解可以參考上一篇文章的相關(guān)部分),
provider包裹的是整個(gè) HomePage 這使得在page內(nèi)部任何地方訪問到bloc成為可能。
home.dart home.dart
在 home.dart 第38,39行代碼中,我們使用provider獲取bloc,并完成對TabBar的初始化。
更進(jìn)一步,上篇文章提到的StreamTransformer可以對Stream進(jìn)行相應(yīng)的處理,同樣的,RxDart中也支持類似的操作,它們被稱為 操作符 。
search_list_bloc.dart search_list_bloc.dart
在上述稍顯復(fù)雜的示例中,實(shí)現(xiàn)了基本的分頁搜索功能。其中13~17行代碼完成搜索索引位置監(jiān)聽前的處理,包括 采樣 (按時(shí)間采樣的緩存操作)、過濾、去重操作。
換句話說,在最終監(jiān)聽到start之前,我們都可以對Observable對象進(jìn)行一系列地處理以達(dá)到數(shù)據(jù)使用方的需求。
相信很多人對于Flutter系列的開篇以響應(yīng)式編程為主題表示有點(diǎn)異議,但谷歌官方推行這一架構(gòu)必然有其合理性,無論是狀態(tài)管理上還是Dart的原生支持上而言。
在學(xué)習(xí)新技術(shù)時(shí)不僅要學(xué)習(xí)語言的語法,更要理解其架構(gòu)思想(新瓶裝舊酒,F(xiàn)lutter和Dart是新瓶,響應(yīng)式編程的思想是舊酒),將思維轉(zhuǎn)變過來才能更加快速地獲得新技術(shù)為我們帶來的便利性。
后續(xù)的文章將圍繞文章開頭的demo項(xiàng)目進(jìn)行展開,盡請期待~
1、Stray birds of summer come to my window to sing and fly away. And yellow leaves of autumn, which have no songs, flutter and fall
there with a sigh.
夏天的飛鳥,飛到我窗前唱歌,又飛去了。
秋天的黃葉,他們沒有什麼可唱的,只是嘆息一聲,飛落在那里。
2、It is the tears of the earth that keep her smiles in bloom.
使大地保持著青春不謝的,是大地的熱淚。
3、The mighty desert is burning for the love of a blade of grass
who shakes her head and laughs and flies away.
偉大的沙漠為了綠葉的愛而燃燒,而她搖搖頭、笑著、飛走了。
4、If you shed tears when you miss the sun, you also miss the stars.
如果你因錯(cuò)過太陽而流淚,那麼你也將錯(cuò)過群星。
5、The sands in you way beg for your song and your movement,dancing water.Will you carry the burden of their lameness?
跳著舞的流水啊!當(dāng)你途中的泥沙為你的歌聲和流動(dòng)哀求時(shí),
你可愿意擔(dān)起他們跛足的重?fù)?dān)?
6、Sorrow is hushed into peace in my heart like the evening among the silent trees.
憂愁在我心中沈寂平靜,正如黃昏在寂靜的林中。
7、I cannot choose the best. The best chooses me.
我不能選擇那最好的,是那最好的選擇了我。
8、They throw their shadows before them who carry their lantern on their back.
把燈籠背在背上的人,有黑影遮住前路。
9、Rest belongs to the work as the eyelids to the eyes.
休息隸屬於工作,正如眼瞼隸屬於眼睛。
10、The waterfall sings, '' I find my song, when I find my freedom.''
瀑布歌道:「當(dāng)我得到自由時(shí),便有了歌聲。」
11、the stars are not afraid to appear like fireflies.
群星不會因?yàn)橄裎灮鹣x而怯於出現(xiàn)。
12、We come nearest to the great when we are great in humility.
當(dāng)我們極謙卑時(shí),則幾近於偉大。
13、The sparrow is sorry for the peacock at the burden of its tail.
麻雀因孔雀馱著翎尾而替它擔(dān)憂。
14、The Perfect decks itself in beauty for the love of the Imperfect.
「完全」為了愛「不完全」,把自己裝飾得更美。
15、'' I give my whole water in joy,'' sings the waterfall,
'' though little of it is enough for the thirsty.''
瀑布歌唱著:「雖然渴者只需少許水便足夠,我卻樂意給與我的全部」
16、The woodcutter's axe begged for its handle from tree, the tree gave it.
樵夫的斧頭向樹要柄,樹便給了它。
17、We read the world wrong and say that it deceives us.
我們看錯(cuò)了世界,卻說世界欺騙了我們。
18、Let life be beautiful like summer flowers and death like autumn leaves.
使生如夏日花朵之絢爛、死如秋天樹葉之靜美。
19、He who wants to do good knocks at the gate; he who loves finds the gate open.
想要行善的人在門外敲著門;愛人的,看見門是敞開的。
20、The scabbard is content to be dull when it protects the keenness of the word.
劍鞘保護(hù)劍的鋒利,自己卻滿足於它自己的遲鈍。
21、The cloud stood humbly in a corner of the sky, The morning crowned it
with splendour.
白云謙卑地站在天邊,晨光給它披上壯麗的光彩。
22、The dust receives insult and in return offers her flowers.
塵土承受屈辱,卻以鮮花來回報(bào)。
23、God is ashamed when the prosperous boasts of his special favour.
當(dāng)富貴利達(dá)的人夸說他得到上帝的恩惠時(shí),上帝卻羞了。
24、Not hammer-strokes, but dance of the water sings the pebbles into perfection.
不是鎚的敲打,乃是水的載歌載舞,使鵝卵石臻於完美。
25、God's great power is in the gentle breeze, not in the storm.
上帝的大能在柔和的微風(fēng)中,不在狂風(fēng)暴雨中。
26、By plucking her petals you do not gather the beauty of the flower.
采擷花瓣得不著花的美麗。
27、The great walks with the small without fear. The middling keeps aloof.
大的不怕與小的同游,居中的卻遠(yuǎn)避之。
28、'' The learned say that your lights will one day be no more.'' said
the firefly to the stars.The stars made no answer.
螢火蟲對群星說:「學(xué)者說你的光有一天會熄滅。」群星不回答它。
29、The pet dog suspects the universe for scheming to take its place.
小狗懷疑大宇宙陰謀篡奪它的位置。
30、God loves man's lamp-lights better than his own great stars.
上帝喜愛人間的燈光甚於他自己的大星。
31、Praise shames me, for I secretly beg for it.
榮譽(yù)羞著我,因?yàn)槲野档乩镒非笾?/p>
32、Life has become richer by the love that has been lost.
生命因?yàn)槭矍槎S盛。
33、Dark clouds becomes heaven's flowers when kissed by light.
黑云受到光的接吻時(shí),就變成了天上的花朵。
34、The little flower lies in the dust. It sought the path of the butterfly.
小花睡在塵土里,它尋求蝴蝶走的路。
35、Let this be my last word, that I trust in thy love.
我相信你的愛」讓這句話作為我最后的話。
文章名稱:flutter小說分頁,flutter小說仿真翻頁
文章網(wǎng)址:http://chinadenli.net/article1/dsgipid.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站維護(hù)、搜索引擎優(yōu)化、網(wǎng)站營銷、外貿(mào)網(wǎng)站建設(shè)、用戶體驗(yàn)、動(dòng)態(tài)網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)