Flutter: infinite list example

這是一個flutter infinite list example: 

https://github.com/flutter/samples/tree/master/infinite_list

看不太懂,目前還在研究中...

void main() {
runApp(MyApp());
}

class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ChangeNotifierProvider<Catalog>(
create: (context) => Catalog(),
child: MaterialApp(
title: 'Infinite List Sample',
home: MyHomePage(),
),
);
}
}

class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Infinite List Sample'),
),
body: Selector<Catalog, int?>(
// Selector is a widget from package:provider. It allows us to listen
// to only one aspect of a provided value. In this case, we are only
// listening to the catalog's `itemCount`, because that's all we need
// at this level.
selector: (context, catalog) => catalog.itemCount,
builder: (context, itemCount, child) => ListView.builder(
// When `itemCount` is null, `ListView` assumes an infinite list.
// Once we provide a value, it will stop the scrolling beyond
// the last element.
itemCount: itemCount,
padding: const EdgeInsets.symmetric(vertical: 18),
itemBuilder: (context, index) {
// Every item of the `ListView` is individually listening
// to the catalog.
var catalog = Provider.of<Catalog>(context);

// Catalog provides a single synchronous method for getting
// the current data.
var item = catalog.getByIndex(index);

if (item.isLoading) {
return LoadingItemTile();
}

return ItemTile(item: item);
},
),
),
);
}
}

 1.可以知道的是這是用 ListView.builder

2. 還用到很多 Future<ItemPage> fetchPage(int startingIndex) async 語法....

3. app using provider. 


然後這個listview沒有 scroll indicator.

又要自己加:

可參考一下這個連結:

https://stackoverflow.com/questions/53030672/flutter-how-to-add-scroll-indicator-in-listview

跟android差很多...


留言

這個網誌中的熱門文章

最爛的銀行服務-玉山銀行

Mark App Design Apps - Terms and Privacy Policy (服務條款,隱私權政策)

SMR疊瓦式hdd致命缺陷被解決????!!!

ios app 上架時app icon要注意事項

更改google drive預設存放目錄位置Change Google Drive Default Folder Location in Windows

舊有app在Android 12 閃退問題& app Splash screens

google play 正式發布前測試報告...非常好用.

app bundle and bundletool. 關於aab安裝問題

關於google play console app應用程式簽署

Google Play badge徽章產生器