系統(tǒng)自帶的Dialog實(shí)際上就是Push了一個(gè)新頁面,這樣存在很多好處,但是也存在一些很難解決的問題
成都創(chuàng)新互聯(lián)公司專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于網(wǎng)站制作、做網(wǎng)站、平鄉(xiāng)網(wǎng)絡(luò)推廣、成都微信小程序、平鄉(xiāng)網(wǎng)絡(luò)營銷、平鄉(xiāng)企業(yè)策劃、平鄉(xiāng)品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運(yùn)營等,從售前售中售后,我們都將竭誠為您服務(wù),您的肯定,是我們最大的嘉獎(jiǎng);成都創(chuàng)新互聯(lián)公司為所有大學(xué)生創(chuàng)業(yè)者提供平鄉(xiāng)建站搭建服務(wù),24小時(shí)服務(wù)熱線:028-86922220,官方網(wǎng)址:www.rwnh.cn
上面這些痛點(diǎn),簡直個(gè)個(gè)致命 ,當(dāng)然,還存在一些其它的解決方案,例如:
很明顯,使用Overlay可移植性最好,目前很多toast和dialog三方庫便是使用該方案,使用了一些loading庫,看了其中源碼,穿透背景解決方案,和預(yù)期想要的效果大相徑庭、一些dialog庫自帶toast顯示,但是toast顯示卻又不能和dialog共存(toast屬于特殊的信息展示,理應(yīng)能獨(dú)立存在),導(dǎo)致我需要多依賴一個(gè)Toast庫
基于上面那些難以解決的問題,只能自己去實(shí)現(xiàn),花了一些時(shí)間,實(shí)現(xiàn)了一個(gè)Pub包,基本該解決的痛點(diǎn)都已解決了,用于實(shí)際業(yè)務(wù)沒什么問題
使用 FlutterSmartDialog 包裹下child即可,下面就可以愉快的使用SmartDialog了
使用Overlay的依賴庫,基本都存在一個(gè)問題,難以對(duì)返回事件的監(jiān)聽,導(dǎo)致觸犯返回事件難以關(guān)閉彈窗布局之類,想了很多辦法,沒辦法在依賴庫中解決該問題,此處提供一個(gè) BaseScaffold ,在每個(gè)頁面使用 BaseScaffold ,便能解決返回事件關(guān)閉Dialog問題
當(dāng)時(shí)想解決穿透暗色背景,和背景后面的控件互動(dòng)的時(shí)候,我?guī)缀趿ⅠR想到這倆個(gè)控件,先了解下這倆個(gè)控件吧
分析
這種方案,成功實(shí)現(xiàn)想要的穿透效果,這里了解下 behavior 的幾種屬性
有戲了!很明顯translucent是有希望的,嘗試了幾次,然后成功實(shí)現(xiàn)了想要的效果
注意,這邊有幾個(gè)坑點(diǎn),提一下
下面是寫的一個(gè)驗(yàn)證小示例
這個(gè)庫花了一些時(shí)間去構(gòu)思和實(shí)現(xiàn),算是解決幾個(gè)很大的痛點(diǎn)
FlutterSmartDialog一些信息
狀態(tài)管理
在平平淡淡的日常中,大家都不可避免地要接觸到作文吧,作文是人們以書面形式表情達(dá)意的言語活動(dòng)。如何寫一篇有思想、有文采的作文呢?下面是我整理的高三英語作文10篇,歡迎閱讀與收藏。
高三英語作文 篇1
Plan For Wnter Holiday
I’m looking forward to the coming of my winter holiday. In order to have a good time in the vacation, I have made a plan for it. At first, my mother must ask me to do homework. If I don’t follow her words, I wouldn’t have peace in the following days until I finish my homework. So the first thing I will do in the winter holiday is to finish my homework. And then I will take full use of my time to go out play with my friends, because I will have to help my mother to prepare for the Spring Festival when it’s in the corner. Three days before Spring Festival, I will go to my grandmother’s home for a visit with my parents. After the Spring Festival I am going to travel with my family. As for where to go, I don’t have any plan now. Maybe we will go to Harbin to the snow. Being the southern local person, I have never seen snow and eager to see it once. After the trip, I think I have to go back to school. This is my plan for the coming winter vacation. What’s yours?
寒假計(jì)劃
我期待寒假的到來。為了過一個(gè)愉快的假期,我制定了一個(gè)寒假計(jì)劃。首先,我的媽媽肯定會(huì)叫我去寫作業(yè)的。如果我不聽她的話,在接下來的日子里我就不會(huì)過得安寧,除非我完成了作業(yè)。所以寒假里我要做的第一件事就是完成我的作業(yè)。然后我會(huì)充分利用我的時(shí)間去和我的朋友玩,因?yàn)樵诖汗?jié)即將到來的時(shí)候我要幫我媽媽準(zhǔn)備春節(jié)的事情。春節(jié)前三天,我會(huì)和爸爸媽媽去外婆家。春節(jié)后我打算與我的家人去旅行。至于去哪里,我還沒有計(jì)劃。也許為了看雪我們會(huì)去哈爾濱。作為南方本地人,我從未見過雪,很希望能看一次。旅行之后,我想我也該準(zhǔn)備回學(xué)校了。這是我即將到來的假期計(jì)劃。你的是什么呢?
高三英語作文 篇2
Notice
In order to make our school life colorful and improve our English skills, we’re going to hold an English Play Show at 8:00 p.m. this Saturday, April 10th. in the meeting room, No.2 Teaching building, At the English Play Show, we can not only enjoy other’s plays and speeches, but also sing songs and play games. What’s more, our foreign teacher Mike will give a talk about how to improve oral English. I hope anyone who comes here will have a great time. If you’d like to come , please sign your name at the Students’ Union, Room 203, Office building.
為了使我們的學(xué)校生活更加的豐富多彩,提高我們的英語水平,我們要在四月十日本星期六下午八點(diǎn)在會(huì)議室2號(hào)教學(xué)樓舉行英語戲劇表演。在英語戲劇表演中我們不僅可以欣賞其他的戲劇和演講,還可以唱歌,玩游戲。更重要的是,我們的外教邁克會(huì)給我們做一個(gè)關(guān)于如何提高英語口語的討論。我希望來的人都能玩得開心。如果你愿意來,請(qǐng)?jiān)趯W(xué)生會(huì),辦公樓203室簽名。
April 7th, 20xx
Students’ Union
高三英語作文 篇3
The first fall of snow is not only an event but it is a magical event. You go to bed in one kind of world and wake up to find yourself in another quite different, and if this is not enchantment, then where is it to be found?
The very stealth, the eerie quietness, of the thing makes it more magical. Ifall the snow fell at once in one shattering crash, awakening us in the middle of the night the event would be robbed of its wonder. But it flutters down, soundless, hour after hour while we are asleep. Outside the closed curtains of the bedroom a vast transfbrmation scene is takiag place, just as if a myriad elves and brownies were at work, and we turn and yawn and stretch and know nothing about it. And then, what an extraordinary change it is! It is as if the house continent. Even the inside, which has not been touched, seems different, every room appearing smaller and cosier, just as if some power were trying to turn it into a woodcutter’s hut or a snug logcabin. Outside, where the garden was yesterday, there is now a white and glistening level, and the village beyond is no longer your own familiar cluster of roofs but a village in an old German fairy-tale.
You would not be surprised to learn that all the people there, the speetacled postmistress, the cobbler, the retired school master, and the rest, had suffered a change too and had become queer elvish beings, purveyors of invisible caps and magic shoes. You yourselves do not feel quite the same people you were yesterday. How could you not when so much has been changed? There is a curious stir, a little shiver of excite-ment, troubling the house, not unlike the feeling there is abroad when a journey has to be made. The children, of course, are all excitement but even the adults hang about and talk to one another longer than usual before setting down to the day’s work. Nobody can resist the windows. It is like being on board a ship.
高三英語作文 篇4
If the most beautiful season of the year is spring, for me, the most interesting festival of the year is the new year's Eve! On that day, we should not only eat family reunion dinner, but also staying-up late on new year's eve.
Remember that the day to eat reunion dinner, people began to play cards, chat, play mahjong, our children, began playing the fun of firecrackers, there are all kinds of varieties, "this" and "Scud", "delta ray" and so on, we played awfully.
I also went to the house to see from time to time and funny TV comic sketch "Spring Festival Gala" performance, I and my buddy will laugh and laugh, see magic in those big magician performing magic show, we were amazed.
Time flies, blink of an eye to 11:45, suddenly rang out a loud bursts of firecrackers, we are excited to join them, just open the door, I saw the fireworks are riotous with colour dark sky dancers.
At 11:50, we can't wait to just wrapped dumplings into the boiling water, mom and dad put a cover on the pot, cook for a while, 12 o'clock, finally boil the dumplings, grandma and grandpa a sung, I smell from afar dumplings fragrance, went straight to the kitchen, when the taste delicious dumplings, happy in the heart.
One year spent similar, each year is different, when the new year's Eve, it means spring is coming, the new year has begun!!!
高三英語作文 篇5
保護(hù)樹木Protect the TreesEach year, people burn or cut down 143,000 square kilometers (55,000 square miles) of the forest. People who burn or cut down trees do it for different reasons: farmers cut down trees in order to get more fertilize lands to grow rice or vegetables, and use the woods as fuel. Timber companies cut down trees and turn them into furniture or paper productions. As to goal miners, they remove the forests to find out whether there are goal underground.每一年,人們都會(huì)砍伐14.3萬平方千米的森林(約5.5萬平方英里)。人們砍伐樹木出于種種原因:農(nóng)民們?yōu)榱说玫礁饰值目盏貋矸N植大米蔬菜,砍下的樹木用來取火。木材公司用樹木來制作家具或是各類紙制品。至于那些開采煤礦的人,把樹木砍掉就是為了檢測(cè)是否有煤礦在下面。
However, many of us fail to realize that forests are the lungs of the earth. When we cut down trees, we also push ourselves in to a dangerous situation. That is the global warming. When you come to think about it, there are only few ways to solve these negative effects: stop cutting down trees blindly; try to find some clear energy that can replace oil and coal. But these solutions can be impractical to some degreed.然而,我們中的許多人都沒有意識(shí)到樹木等同于地球的“肺部”。當(dāng)我們砍伐樹木時(shí),我們就把自己推入一個(gè)危險(xiǎn)的境地——會(huì)引起全球氣候變暖。想到這些,只有為數(shù)不多的幾個(gè)辦法可以解決這個(gè)問題:停止盲目地砍伐樹木;尋找可以代替石油和煤礦的新能源。但是,就目前來看,這幾個(gè)策略并不可行。
Why trees can be so important to the whole nature? First of all, trees are the habitat of many animals. When we cut down trees, we not only destroy animals’ habitats but also ourselves. We just gradually destroy natural links. The result is that many spices of animals and plants are dying out. Secondly, cutting down trees cause global warming, to some degree. Naturalists compare forest to human’s lungs. The forests absorb the carbon dioxide and other gas that cause global warming, and then give off the oxygen that good for the human beings and other living creatures. It’s refreshed the air as well as reduced the noise. If the air quality is bad, people may die from cancers, or the new diseases for which they have no immunity. Forests also play an important role in the prevention of natural disasters. Warmer temperatures cause water to expand and also create more water by melting polar ice caps. That’s to say, the nations which near the ocean may have been flooded by the water. But the forests can prevent water loss and soil erosion, and cool off the global temperatures. It’s the key to keep the balance of the nature.為什么樹木對(duì)整個(gè)生態(tài)環(huán)境都如此重要呢?首先,樹木是小動(dòng)物們的家園。當(dāng)我們砍伐樹木時(shí),我們不僅僅毀掉了它們的家,也毀掉了自己的。一步步的,我們慢慢分解了整個(gè)生態(tài)鏈,所造成的結(jié)果就是大批的動(dòng)植物種類滅絕。其二,砍伐樹木在某種程度上造成全球變暖。生態(tài)學(xué)家把森林比作人類的肺。森林能夠吸收二氧化碳和其他引起氣候變暖的溫室氣體,然后轉(zhuǎn)化成氧氣供地球上的生物呼吸。樹木不僅能凈化空氣,也能減少噪音。如果空氣質(zhì)量下降,那么人們就有可能死于肺癌,或者是其他致命菌。森林在預(yù)防疾病的過程中起到了重要的角色。氣溫的上升導(dǎo)致北極的冰層融化,水平面上升。也就是說,臨海的城市也許會(huì)被海水淹沒。但是森林就能夠阻止水土流失,使氣溫下降。它是保證全球生態(tài)平衡的關(guān)鍵。
Sometimes people only care about money making; they don’t care about the price we pay for the pollution. When the disaster is around the corner, we may be afraid and frustrated. The earth, on which our economies have always been based, is suddenly threatening our existence. All we hope that is this overpopulated, over industrialized planet can carry on for a longer time. And maybe, it’s time for us to realize that we should protect the earth, stop cutting down trees blindly and madly.有時(shí)候人們只關(guān)心掙錢,卻對(duì)我們所付出的代價(jià)不管不問。當(dāng)災(zāi)難來臨時(shí),我們會(huì)害怕、會(huì)彷徨。我們賴以生存的地球,卻突然變成了威脅我們生命的東西。我們只希望,在這個(gè)人口過度、工業(yè)過度的星球能繼續(xù)撐下去。也許,是時(shí)候我們應(yīng)該保護(hù)地球,停止盲目瘋狂地砍伐樹木了。
高三英語作文 篇6
My View on Hobby
Everybody has his own hobby. Hobbies not only make our life colorful, but also bring us lots of benefits. Hobbies help us to relax after a long period of hard work, and offer various activities for the people who are retiring. As to my mother, her hobby is to go square dancing after supper. She said, square dancing can make her forget her own problems and stay in good health. As to my father, his hobby is watching football games on TV. Among all my hobbies, the favorite one is reading. When I was a little girl, I love reading comic books. When I m getting old, I love fiction very much. I have so much fun from reading them. My favorite fiction is Pride and Prejudice. It not only provides knowledge, but also teaches us the right attitude toward life. I think reading makes my life complete. I will keep on reading. That s my favorite hobby.
興趣愛好之我見
每個(gè)人都有自己的興趣愛好。愛好不僅讓我們的生活變得豐富多彩,也給予了我們諸多好處。愛好有助于我們?cè)陂L時(shí)間的工作后得到放松,還為退休的人們提供各種各樣的活動(dòng)。就我媽媽來說,她最大的興趣愛好就是晚飯之后去跳廣場(chǎng)舞。她說,廣場(chǎng)舞讓她忘記了自己的煩惱,保持身體健康。至于我爸爸,他最喜歡看足球比賽。就我自己來說,在我所以的愛好里面,我最喜歡的就是閱讀小說。當(dāng)我還是個(gè)小女孩的時(shí)候,我很喜歡看動(dòng)漫。長大一點(diǎn)的`時(shí)候,我愛上了小說??葱≌f充滿了樂趣。我最喜愛的小說是《傲慢與偏見》。它不僅教給了我很多知識(shí),也讓我對(duì)人生有了個(gè)正確的態(tài)度。閱讀使我的生活變得完整,我會(huì)一直讀下去,因?yàn)檫@是我的愛好所在。
高三英語作文 篇7
日記:高三學(xué)習(xí)十分緊張,所以班長建議本周去郊外放松一下,享受秋天的美景。請(qǐng)你在今天的日記里發(fā)表對(duì)班長建議的想法。
October 12, 20xx, Monday Fine
It is universally acknowledged that Senior Three is undoubtedly a critical phase of life. The school life is extremely busy, so our monitor suggests that we have an outing to relax ourselves this weekend.
It is terrific! After a month s study, I feel we really need a break for one day, and so do some of my friends. Senior Three should not be filled with study only and relaxation is also an important part. Sometimes relaxation is more useful than an hour s hard work. While having an outing, we can relax ourselves and enjoy the beautiful scenery of autumn --- yellow leaves, attractive sunset against the blue sky and so on. Isn t it enjoyable? After the outing, I think all the students will have a better physical and mental state to meet the further challenges we may come across and cope with difficulties for ourselves.
高三英語作文 篇8
I like Christmas, it is just like our Spring Festival.
Maybe the Spring Festival is much more important and interesting than Christmas, but I like Christmas Day better. Because we can spend time with our friends and classmates during Christmas. When it is snowy,
Christmas becomes much more lovely, just like in fairytales. I can imagine I am in a fairytale, the girl who sold the matches is my friend, the ugly duck becoming more and more beautiful and so on. What a beautiful place! So we can also call Christmas “Snowy Lovely Day.”
On Christmas Day, shops are red and green. There are so many Christmas cards, Christmas hats, Christmas dolls and many colourful things. So shops look very beautiful. We can give a card or a doll to our friends and say “Merry Christmas.” By the way, I think studying can also become much more interesting.
Christmas is coming, it also means a new year will come. Let’s study harder to welcome
我喜歡圣誕節(jié),它就像我們的春節(jié)。
也許春節(jié)比圣誕節(jié)更重要和有趣的,但我更喜歡圣誕節(jié)。因?yàn)槲覀兛梢曰〞r(shí)間與我們的朋友和同學(xué)在圣誕節(jié)。當(dāng)它下雪的,
圣誕節(jié)變得更加可愛,就像在童話。我可以想象我在童話中,賣火柴的女孩是我的朋友,丑鴨越來越漂亮等等。一個(gè)美麗的地方!我們也可以叫圣誕“雪可愛的一天?!?/p>
在圣誕節(jié)這一天,商店是紅色和綠色。有很多圣誕卡,圣誕帽、圣誕娃娃和許多五顏六色的東西。所以商店看起來很漂亮。我們可以給我們的朋友和一個(gè)卡或一個(gè)娃娃說“圣誕快樂?!绊槺阏f一下,我覺得學(xué)習(xí)也可以變得更有趣。
圣誕節(jié)即將來臨,這也意味著新的一年。讓我們更加努力地學(xué)習(xí),歡迎
高三英語作文 篇9
你知道是什么在維系著我們的生命嗎?是血液。血液一直被視為活力與健康之源,具有重要的生理意義。如今,越來越多的人愿意獻(xiàn)血,而且還是無償獻(xiàn)血,它已經(jīng)成為了愛的奉獻(xiàn)。這不,一件件感人的事例正在涌上心頭
你一定知道周杰倫,一定喜歡韓庚,但是,你知道王則謙嗎?王則謙是一個(gè)普通的農(nóng)民。每過三個(gè)月,他都會(huì)走上幾十里的山路到縣城,然后車到血液中心,為的是在這里捐獻(xiàn)出一份機(jī)采血小板。11年了,無論刮風(fēng),下雨,還是農(nóng)忙農(nóng)閑,他一直默默堅(jiān)持著。
王則謙啊王則謙,你讓我們知道原來需要堅(jiān)持的,并不一定是某一習(xí)慣或自己的夢(mèng)想。我們還可以去獻(xiàn)血。本著“無償獻(xiàn)血,拯救生命 ”的思想,讓無數(shù)條生命可以重新看到生命的曙光,可以與我們生活在這美好的人間。
接下來,要跟大家介紹的是一位鮮血英雄。這位英雄,5年間無償獻(xiàn)血毫升。這是一個(gè)什么量呢?它相當(dāng)于5個(gè)成年人全身的血液。而做出這個(gè)壯舉的只是一位普通工人——郭青建。但遺憾的是這位英雄的生命因?yàn)橐淮诬嚨湺┤欢?。直到這時(shí),人們才知道,他把獻(xiàn)血當(dāng)成他畢生的榮耀。我注視著屏幕里這位英雄的遺像,以及他留下的14本獻(xiàn)血證與3本全國獻(xiàn)血榮譽(yù)證書,我的眼睛濕潤了。在這里,讓我們對(duì)英雄說,一路走好!
無償獻(xiàn)血者出于高尚的救死扶傷的目的去獻(xiàn)血,是一種“人人為我,我為人人 ”的社會(huì)共濟(jì)行為,是一種愛的奉獻(xiàn),是人道主義精神的重要體現(xiàn)。
實(shí)行無償獻(xiàn)血,有利于弘揚(yáng)中華民族的傳統(tǒng)美德,也是促進(jìn)文明建設(shè)的一項(xiàng)重要舉措。每一個(gè)健康公民都應(yīng)積極參與。我想,等我成年了,我也要去獻(xiàn)血呢!
Do you know what sustains our lives? It's blood. Blood has been regarded as the source of vitality and health, and has important physiological significance. Nowadays, more and more people are willing to donate blood, but also unpaid blood donation, it has become the dedication of love. No, a moving story is pouring in
You must know Jay Chou. You must like Han Geng, but do you know Wang Zeqian? Wang Zeqian is an ordinary farmer. Every three months, he would walk dozens of miles of mountain roads to the county seat, and then the car to the blood center, in order to donate a apheresis platelet here. For 11 years, regardless of wind and rain, busy or slack, he has been quietly persisted.
Wang Zeqian ah, Wang Zeqian, you let us know that the original need to adhere to, not necessarily a habit or own dream. We can also donate blood. In accordance with the idea of "donating blood without blood and saving lives", countless lives can see the dawn of life again, and can live with us in this wonderful world.
Next, I'd like to introduce you to a blood hero. The hero has donated blood for 5 years. What amount is this? It's equivalent to the blood of 5 adults. And the only one who made this feat was Guo Qingjian, an ordinary worker. But unfortunately, the hero's life ended abruptly because of a car accident. Until then, people knew that he had donated blood as his lifelong glory. I watched the hero portrait screen, and he left the 14 and the 3 national blood donation certificate certificate of honor, my eyes moist. Here, let's say to the hero, all the way!
Blood donors for the noble life-saving purpose to donate blood, is a kind of "all for me, I for social relief behavior all", is a kind of love, is an important manifestation of the humanitarian spirit.
The implementation of voluntary blood donation is conducive to carrying forward the traditional virtues of the Chinese nation, and is also an important measure to promote civilization construction. Every healthy citizen should take an active part in it. I think, when I'm adult, I'm going to donate blood!
高三英語作文 篇10
Thanks for your last letter. Don’t worry about my new school life here. I’m fine here because I like my new school life. My new school life is busy but interesting. Every day I get to school at 7:00 am and go home at 4:30 pm. We have four classes in the morning and three classes in the afternoon. My favorite day is Thursday, because I have English and art that day. The two subjects are my favorite. But I don’t like math, because it’s difficult. At school, I also have a new friend, Zhang Qiang. He often helps me with math. After school, I often have art club with him.
Uniapp目前比較成熟,而且用的是Vue語法,學(xué)習(xí)成本比較低,而且行業(yè)里面用的也比較廣泛,而Flutter的話,學(xué)習(xí)成本略高,因?yàn)橐獙W(xué)習(xí)新的語言,還有就是目前生態(tài)不是特別完備,等他再發(fā)展發(fā)展吧。黑馬程序員官網(wǎng)有成套免費(fèi)視頻哦,有什么不懂的可以直接過去學(xué)習(xí)。您的采納是對(duì)我成長的鞭策
文/陳爐軍
整理/LiveVideoStack
大家好,我是阿里巴巴閑魚事業(yè)部的陳爐軍,本次分享的主題是Flutter浪潮下的音視頻研發(fā)探索,主要內(nèi)容是針對(duì)閑魚APP在當(dāng)下流行的跨平臺(tái)框架Flutter的大規(guī)模實(shí)踐,介紹其在音視頻領(lǐng)域碰到的一些困難以及解決方案。
分享內(nèi)容主要分為四個(gè)方面,首先會(huì)對(duì)Flutter有一個(gè)簡單介紹以及選擇Flutter作為跨平臺(tái)框架的原因,其次會(huì)介紹Flutter中與音視頻關(guān)系非常大的外接紋理概念,以及對(duì)它做出的一些優(yōu)化。之后會(huì)對(duì)閑魚在音視頻實(shí)踐過程中碰到的一些Flutter問題提出了一些解決方案——TPM音視頻框架。最后是閑魚Flutter多媒體開源組件的介紹。
Flutter
Flutter是一個(gè)跨平臺(tái)框架,以往的做法是將音頻、視頻和網(wǎng)絡(luò)這些模塊都下沉到C++層或者ARM層,在其上封裝成一個(gè)音視頻的SDK,供UI層的PC、iOS和Android調(diào)用。
而Flutter做為一個(gè)UI層的跨平臺(tái)框架,顧名思義就是在UI層也實(shí)現(xiàn)了一個(gè)跨平臺(tái)開發(fā)??梢灶A(yù)想的是未Flutter發(fā)展的好的話,會(huì)逐漸變?yōu)橐粋€(gè)從底層到UI層的一個(gè)全鏈路的跨平臺(tái)開發(fā),技術(shù)人員分別負(fù)責(zé)SDK和UI層的開發(fā)。
在Flutter之前已經(jīng)有很多跨平臺(tái)UI解決方案,那為什么選擇Flutter呢?
我們主要考慮性能和跨平臺(tái)的能力。
以往的跨平臺(tái)方案比如Weex,ReactNative,Cordova等等因?yàn)榧軜?gòu)的原因無法滿足性能要求,尤其是在音視頻這種性能要求幾乎苛刻的場(chǎng)景。
而諸如Xamarin等,雖然性能可以和原生App一致,但是大部分邏輯還是需要分平臺(tái)實(shí)現(xiàn)。
我們可以看一下,為什么Flutter可以實(shí)現(xiàn)高性能:
原生的native組件渲染以IOS為例,蘋果的UIKit通過調(diào)用平臺(tái)自己的繪制框架QuaztCore來實(shí)現(xiàn)UI的繪制,圖形繪制也是調(diào)用底層的API,比如OpenGL、Metal等。
而Flutter也是和原生API邏輯一致,也是通過調(diào)用底層的繪制框架層SKIA實(shí)現(xiàn)UI層。這樣相當(dāng)于Flutter他自己實(shí)現(xiàn)了一套UI框架,提供了一種性能超越原生API的跨平臺(tái)可能性。
但是我們說一個(gè)框架最終性能怎樣,其實(shí)取決于設(shè)計(jì)者和開發(fā)者。至于現(xiàn)在到底是一個(gè)什么狀況:
在閑魚的實(shí)踐中,我們發(fā)現(xiàn)在正常的開發(fā)沒有特意的去優(yōu)化UI代碼的情況下,在一些低端機(jī)上,F(xiàn)lutter界面的流暢性是比Native界面要好的。
雖然現(xiàn)在閑魚某些場(chǎng)景下會(huì)有卡頓閃退等情況,但是這是一個(gè)新事物發(fā)展過程中的必然問題,我們相信未來性能肯定不會(huì)成為限制Flutter發(fā)展的瓶頸的。
在閑魚實(shí)踐Flutter的過程中,混合棧和音視頻是其中比較難解決的兩個(gè)問題,混合棧是指一個(gè)APP在Flutter過程中不可能一口氣將所有業(yè)務(wù)全部重寫為Flutter,所以這是一個(gè)逐步迭代的過程,這期間原生native界面與Flutter界面共存的狀態(tài)就稱之為混合棧。閑魚在混合棧上也有一些比較好的輸出,例如FlutterBoost。
外接紋理
在講音視頻之前需要簡要介紹一下外接紋理的概念,我們將它稱之為是Flutter和Frame之間的橋梁。
Flutter渲染一幀屏幕數(shù)據(jù)首先要做的是,GPU發(fā)出的VC信號(hào)在Flutter的UI線程,通過AOT編譯的機(jī)器碼結(jié)合當(dāng)前Dart Runtime,生成Layer Tree UI樹,Layer Tree上每一個(gè)葉子節(jié)點(diǎn)都代表了當(dāng)前屏幕上所需要渲染的每一個(gè)元素,包含了這些元素渲染所需要的內(nèi)容。將Layer Tree拋給GPU線程,在GPU線程內(nèi)調(diào)用Skia去完成整個(gè)UI的渲染過程。Layer Tree中有PictureLayer和TextureLayer兩個(gè)比較重要的節(jié)點(diǎn)。PictureLayer主要負(fù)責(zé)屏幕圖片的渲染,F(xiàn)lutter內(nèi)部實(shí)現(xiàn)了一套圖片解碼邏輯,在IO線程將圖片讀取或者從網(wǎng)絡(luò)上拉取之后,通過解碼能夠在IO線程上加載出紋理,交給GPU線程將圖片渲染到屏幕上。但是由于音視頻場(chǎng)景下系統(tǒng)API太過繁多,業(yè)務(wù)場(chǎng)景過于復(fù)雜。Flutter沒有一套邏輯去實(shí)現(xiàn)跨平臺(tái)的音視頻組件,所以說Flutter提出了一種讓第三方開發(fā)者來實(shí)現(xiàn)音視頻組件的方式,而這些音視頻組件的視頻渲染出口,就是TextureLayer。
在整個(gè)Layer Tree渲染的過程中,TextureLayer的數(shù)據(jù)紋理需要由外部第三方開發(fā)者來指定,可以把視頻數(shù)據(jù)和播放器數(shù)據(jù)送到TextureLayer里,由Flutter將這些數(shù)據(jù)渲染出來。
TextureLayer渲染過程:首先判斷Layer是否已經(jīng)初始化,如果沒有就創(chuàng)建一個(gè)Texture,然后將Texture Attach到一個(gè)SufaceTexture上。
這個(gè)SufaceTexture是音視頻的native代碼可以獲取到的對(duì)象,通過這個(gè)對(duì)象創(chuàng)建的Suface,我們可以將視頻數(shù)據(jù)、攝像頭數(shù)據(jù)解碼放到Suface中,然后Flutter端通過監(jiān)聽SufaceTexture的數(shù)據(jù)更新就可以順利把剛才創(chuàng)建的數(shù)據(jù)更新到它的紋理中,然后再將紋理交給SKIA渲染到屏幕上。
然而我們?nèi)绻枰肍lutter實(shí)現(xiàn)美顏,濾鏡,人臉貼圖等等功能,就需要將視頻數(shù)據(jù)讀取出來,更新到紋理中,再將GPU紋理經(jīng)過美顏濾鏡處理后生成一個(gè)處理后的紋理。按Flutter提供的現(xiàn)有能力,必須先將紋理中的數(shù)據(jù)從GPU讀出到CPU中,生成Bitmap后再寫入Surface中,這樣在Flutter中才能順利的更新到視頻數(shù)據(jù),這樣做對(duì)系統(tǒng)性能的消耗很大。
通過對(duì)Flutter渲染過程分析,我們知道Flutter底層需要渲染的數(shù)據(jù)就是GPU紋理,而我們經(jīng)過美顏濾鏡處理完成以后的結(jié)果也是GPU紋理,如果可以將它直接交給Flutter渲染,那就可以避免GPU-CPU-GPU這樣的無用循環(huán)。這樣的方法是可行的,但是需要一個(gè)條件,就是OpenGL上下文共享。
OpenGL
在說上下文之前,得提到一個(gè)和上線文息息相關(guān)的概念:線程。
Flutter引擎啟動(dòng)后會(huì)啟動(dòng)四個(gè)線程:
第一個(gè)線程是UI線程,這是Flutter自己定義的UI線程,主要負(fù)責(zé)GPU發(fā)出的VSync信號(hào)時(shí)候用當(dāng)前Dart編譯的機(jī)器碼和當(dāng)前運(yùn)行環(huán)境創(chuàng)建出Layer Tree。
還有就是IO線程和GPU線程。和大部分OpenGL處理解決方案中一樣,F(xiàn)lutter也采取一個(gè)線程責(zé)資源加載,一部分負(fù)責(zé)資源渲染這種思路。
兩個(gè)線程之間紋理共享有兩種方式。一種是EGLImage(IOS是 CVOpenGLESTextureCache)。一種是OpenGL Share Context。Flutter通過Share Context來實(shí)現(xiàn)紋理共享,將IO線程的Context和GPU線程的Context進(jìn)行Share,放到同一個(gè)Share Group下面,這樣兩個(gè)線程下資源是互相可見可以共享的。
Platform線程是主線程,F(xiàn)lutter中有一個(gè)很奇怪的設(shè)定,GPU線程和主線程共用一個(gè)Context。并且在主線程也有很多OpenGL 操作。
這樣的設(shè)計(jì)會(huì)給音視頻開發(fā)帶來很多問題,后面會(huì)詳細(xì)說。
音視頻端美顏處理完成的OpenGL紋理能夠讓Flutter直接使用的條件就是Flutter的上下文需要和平臺(tái)音視頻相關(guān)的OpenGL上下文處在一個(gè)Share Group下面。
由于Flutter主線程的Context就是GPU的Context,所以在音視頻端主線程中有一些OpenGL操作的話,很有可能使Flutter整個(gè)OpenGL被破壞掉。所以需要將所有的OpenGL操作都限制在子線程中。
通過上述這兩個(gè)條件的處理,我們就可以在沒有增加GPU消耗的前提下實(shí)現(xiàn)美顏和濾鏡等等功能。
TPM
在經(jīng)過demo驗(yàn)證之后,我們將這個(gè)方案應(yīng)用到閑魚音視頻組件中,但改造過程中發(fā)現(xiàn)了一些問題。
上圖是攝像頭采集數(shù)據(jù)轉(zhuǎn)換為紋理的一段代碼,其中有兩個(gè)操作:首先是切進(jìn)程,將后面的OpenGL操作都切到cameraQueue中。然后是設(shè)置一次上下文。然后這種限制條件或者說是潛規(guī)則往往在開發(fā)過程中容易被忽略的。而這個(gè)條件一旦忽略后果就是出現(xiàn)一些莫名其妙的詭異問題極難排查。因此我們就希望能抽象出一套框架,由框架本身實(shí)現(xiàn)線程的切換、上下文和模塊生命周期等的管理,開發(fā)者接入框架以后只需要安心實(shí)現(xiàn)自己的算法,而不需要關(guān)心這些潛規(guī)則還有其他一些重復(fù)的邏輯操作。
在引入Flutter之前閑魚的音視頻架構(gòu)與大部分音視頻邏輯一樣采用分層架構(gòu):
1:底層是一些獨(dú)立模塊
2:SDK層是對(duì)底層模塊的封裝
3:最上層是UI層。
引入Flutter之后,通過分析各個(gè)模塊的使用場(chǎng)景,我們可以得出一個(gè)假設(shè)或者說是抽象:音視頻應(yīng)用在終端上可以歸納為視頻幀解碼之后視頻數(shù)據(jù)幀在各個(gè)模塊之間流動(dòng)的過程,基于這種假設(shè)去做Flutter音視頻框架的抽象。
咸魚Flutter多媒體開源組件
整個(gè)Flutter音視頻框架抽象分為管線和數(shù)據(jù)的抽象、模塊的抽象、線程統(tǒng)一管理和上下文同一管理四部分。
管線,其實(shí)就是視頻幀流動(dòng)的管道。數(shù)據(jù),音視頻中涉及到的數(shù)據(jù)包括紋理、Bit Map以及時(shí)間戳等。結(jié)合現(xiàn)有的應(yīng)用場(chǎng)景我們定義了管線流通數(shù)據(jù)以Texture為主數(shù)據(jù),同時(shí)可以選擇性的添加Bit Map等作為輔助數(shù)據(jù)。這樣的數(shù)據(jù)定義方式,避免重復(fù)的創(chuàng)建和銷毀紋理帶來的性能開銷以及多線程訪問紋理帶來的一些問題。也滿足一些特殊模塊對(duì)特殊數(shù)據(jù)的需求。同時(shí)也設(shè)計(jì)了紋理池來管理管線中的紋理數(shù)據(jù)。
模塊:如果把管線和數(shù)據(jù)比喻成血管和血液,那框架音視頻的場(chǎng)景就可以比喻成器官,我們根據(jù)模塊所在管線的位置抽象出采集、處理和輸出三個(gè)基類。這三個(gè)基類里實(shí)現(xiàn)了剛才說的線程切換,上下文切換,格式轉(zhuǎn)換等等共同邏輯,各個(gè)功能模塊通過集成自這些基類,可以避免很多重復(fù)勞動(dòng)。
線程:每一個(gè)模塊初始化的時(shí)候,初始化函數(shù)就會(huì)去線程管理的模塊去獲取自己的線程,線程管理模塊可以決定給初始化函數(shù)分配新的線程或者已經(jīng)分配過其他模塊的線程。
這樣有三個(gè)好處:
一是可以根據(jù)需要去決定一個(gè)線程可以掛載多少模塊,做到線程間的負(fù)載均衡。第二,多線程并發(fā)式能夠保證模塊內(nèi)的OpenGL操作是在當(dāng)前線程內(nèi)而不會(huì)跑到主線程去,徹底避免Flutter的OpenGL 環(huán)境被破壞。第三,多線程并行可以充分利用CPU多核架構(gòu),提升處理速度。
從Flutter端修改Flutter引擎將Context取出后,根據(jù)Context創(chuàng)建上下文的統(tǒng)一管理模塊,每一個(gè)模塊在初始化的時(shí)候會(huì)獲取它的線程,獲取之后會(huì)調(diào)用上下文管理模塊獲取自己的上下文。這樣可以保證每一個(gè)模塊的上下文都是與Flutter的上下文進(jìn)行Share的,每個(gè)模塊之間資源都是共享可見的,F(xiàn)lutter和音視頻native之間也是互相共享可見的。
基于上述框架如果要實(shí)現(xiàn)一個(gè)簡單的場(chǎng)景,比如畫面實(shí)時(shí)預(yù)覽和濾鏡處理功能,
1:需要選擇功能模塊,功能模塊包括攝像頭模塊、濾鏡處理模塊和Flutter畫面渲染模塊,
2:需要配置模塊參數(shù),比如采集分辨率、濾鏡參數(shù)和前后攝像頭設(shè)置等,
3:在創(chuàng)建視頻管線后使用已配置的參數(shù)創(chuàng)建模塊
4:最后管線搭載模塊,開啟管線就可以實(shí)現(xiàn)這樣簡單的功能。
上圖為整個(gè)功能實(shí)現(xiàn)的代碼和結(jié)構(gòu)圖。
結(jié)合上述音視頻框架,閑魚實(shí)現(xiàn)了Flutter多媒體開源組件。
組要包含四個(gè)基本組件分別是:
1:視頻圖像拍攝組件
2:播放器組件
3:視頻圖像編輯組件
4:相冊(cè)選擇組件
現(xiàn)在這些組件正在走內(nèi)部開源流程。預(yù)計(jì)9月份,相冊(cè)和播放器會(huì)實(shí)現(xiàn)開源。
后續(xù)展望和規(guī)劃
1:實(shí)現(xiàn)開頭所說的從底層SDK到UI的全鏈路的跨端開發(fā)。目前底層框架層和模塊層都是各個(gè)平臺(tái)各自實(shí)現(xiàn),反而是Flutter的UI端進(jìn)行了跨平臺(tái)的統(tǒng)一,所以后續(xù)會(huì)將底層也按照音視頻常用做法把邏輯下沉到C++層,盡可能的實(shí)現(xiàn)全鏈路跨平臺(tái)。
2:第二部分內(nèi)容為開源共建,閑魚開源的內(nèi)容不僅包括拍攝、編輯組件,還包括了很多底層模塊,希望有開發(fā)者在基于Flutter開發(fā)音視頻應(yīng)用時(shí)可以充分利用閑魚開源出的音視頻模塊能力,搭建APP框架,開發(fā)者只要去負(fù)責(zé)實(shí)現(xiàn)特殊需求模塊就可以,盡可能的減少重復(fù)勞動(dòng)。
自己寫flutter也有段時(shí)間了,這次來聊聊flutter開發(fā)App和原生iOS開發(fā)App各有什么優(yōu)缺點(diǎn).
不廢話,直奔主題????
本文題目:flutter好處,Flutter缺點(diǎn)
文章源于:http://www.rwnh.cn/article34/dsdjcpe.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站設(shè)計(jì)、標(biāo)簽優(yōu)化、Google、云服務(wù)器、微信小程序、網(wǎng)站排名
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)