From ca497b3c827894056c70da6b5b7df3fd58ef73c3 Mon Sep 17 00:00:00 2001 From: Location <59411633+James-Lu-none@users.noreply.github.com> Date: Thu, 26 Oct 2023 22:29:22 +0800 Subject: [PATCH 1/4] Wrap FutureBuilder with Expanded widget --- .../pages/other/page/contributors_page.dart | 94 ++++++++++--------- 1 file changed, 48 insertions(+), 46 deletions(-) diff --git a/lib/ui/pages/other/page/contributors_page.dart b/lib/ui/pages/other/page/contributors_page.dart index 4e6ef280..9f14abf8 100644 --- a/lib/ui/pages/other/page/contributors_page.dart +++ b/lib/ui/pages/other/page/contributors_page.dart @@ -88,59 +88,61 @@ class ContributorsPage extends StatelessWidget { ) ], ), - FutureBuilder>( - future: github.repositories.listContributors(repositorySlug).toList(), - builder: (context, snapshot) { - if (snapshot.hasData) { - final contributorList = snapshot.data; - return ListView.builder( - itemCount: contributorList?.length, - shrinkWrap: true, - itemBuilder: (context, index) { - final contributor = contributorList![index]; + Expanded( + child: FutureBuilder>( + future: github.repositories.listContributors(repositorySlug).toList(), + builder: (context, snapshot) { + if (snapshot.hasData) { + final contributorList = snapshot.data; + return ListView.builder( + itemCount: contributorList?.length, + shrinkWrap: true, + itemBuilder: (context, index) { + final contributor = contributorList![index]; - return InkWell( - onTap: () { - RouteUtils.toWebViewPage(initialUrl: Uri.parse(contributor.htmlUrl ?? '')); - }, - child: WidgetAnimator( - Container( - padding: const EdgeInsets.only(top: 5, bottom: 5, left: 10), - child: Row( - children: [ - SizedBox( - height: 50, - width: 50, - child: CachedNetworkImage( - imageUrl: contributor.avatarUrl ?? '', - imageBuilder: (context, imageProvider) => CircleAvatar( - radius: 15.0, - backgroundImage: imageProvider, + return InkWell( + onTap: () { + RouteUtils.toWebViewPage(initialUrl: Uri.parse(contributor.htmlUrl ?? '')); + }, + child: WidgetAnimator( + Container( + padding: const EdgeInsets.only(top: 5, bottom: 5, left: 10), + child: Row( + children: [ + SizedBox( + height: 50, + width: 50, + child: CachedNetworkImage( + imageUrl: contributor.avatarUrl ?? '', + imageBuilder: (context, imageProvider) => CircleAvatar( + radius: 15.0, + backgroundImage: imageProvider, + ), ), ), - ), - const Padding( - padding: EdgeInsets.only(left: 10), - ), - Text(contributor.login ?? '') - ], + const Padding( + padding: EdgeInsets.only(left: 10), + ), + Text(contributor.login ?? '') + ], + ), ), ), - ), - ); - }, - ); - } else if (snapshot.hasError) { + ); + }, + ); + } else if (snapshot.hasError) { + return const Center( + child: Icon(Icons.error), + ); + } return const Center( - child: Icon(Icons.error), + child: SpinKitDoubleBounce( + color: AppColors.mainColor, + ), ); - } - return const Center( - child: SpinKitDoubleBounce( - color: AppColors.mainColor, - ), - ); - }, + }, + ), ), ], ), From f67b272fe19885766f45d9a55b1343ff1b2827c3 Mon Sep 17 00:00:00 2001 From: Location <59411633+James-Lu-none@users.noreply.github.com> Date: Thu, 26 Oct 2023 22:35:13 +0800 Subject: [PATCH 2/4] Modify Expanded widget warpping scope --- .../pages/other/page/contributors_page.dart | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/ui/pages/other/page/contributors_page.dart b/lib/ui/pages/other/page/contributors_page.dart index 9f14abf8..1ca66e70 100644 --- a/lib/ui/pages/other/page/contributors_page.dart +++ b/lib/ui/pages/other/page/contributors_page.dart @@ -88,13 +88,13 @@ class ContributorsPage extends StatelessWidget { ) ], ), - Expanded( - child: FutureBuilder>( - future: github.repositories.listContributors(repositorySlug).toList(), - builder: (context, snapshot) { - if (snapshot.hasData) { - final contributorList = snapshot.data; - return ListView.builder( + FutureBuilder>( + future: github.repositories.listContributors(repositorySlug).toList(), + builder: (context, snapshot) { + if (snapshot.hasData) { + final contributorList = snapshot.data; + return Expanded( + child:ListView.builder( itemCount: contributorList?.length, shrinkWrap: true, itemBuilder: (context, index) { @@ -130,19 +130,19 @@ class ContributorsPage extends StatelessWidget { ), ); }, - ); - } else if (snapshot.hasError) { - return const Center( - child: Icon(Icons.error), - ); - } - return const Center( - child: SpinKitDoubleBounce( - color: AppColors.mainColor, ), ); - }, - ), + } else if (snapshot.hasError) { + return const Center( + child: Icon(Icons.error), + ); + } + return const Center( + child: SpinKitDoubleBounce( + color: AppColors.mainColor, + ), + ); + }, ), ], ), From db85b52ffd418aed92113aa62154cc876e399dd7 Mon Sep 17 00:00:00 2001 From: Location <59411633+James-Lu-none@users.noreply.github.com> Date: Thu, 26 Oct 2023 23:09:45 +0800 Subject: [PATCH 3/4] dart format --- .../pages/other/page/contributors_page.dart | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/ui/pages/other/page/contributors_page.dart b/lib/ui/pages/other/page/contributors_page.dart index 1ca66e70..544a4aa0 100644 --- a/lib/ui/pages/other/page/contributors_page.dart +++ b/lib/ui/pages/other/page/contributors_page.dart @@ -12,7 +12,8 @@ import 'package:github/github.dart'; class ContributorsPage extends StatelessWidget { final github = GitHub(); - final repositorySlug = RepositorySlug(AppLink.githubOwnerName, AppLink.tatRepoName); + final repositorySlug = + RepositorySlug(AppLink.githubOwnerName, AppLink.tatRepoName); ContributorsPage({super.key}); @@ -57,7 +58,8 @@ class ContributorsPage extends StatelessWidget { children: [ Text( R.current.github, - style: const TextStyle(fontWeight: FontWeight.w600), + style: const TextStyle( + fontWeight: FontWeight.w600), ) ], ), @@ -89,12 +91,14 @@ class ContributorsPage extends StatelessWidget { ], ), FutureBuilder>( - future: github.repositories.listContributors(repositorySlug).toList(), + future: github.repositories + .listContributors(repositorySlug) + .toList(), builder: (context, snapshot) { if (snapshot.hasData) { final contributorList = snapshot.data; return Expanded( - child:ListView.builder( + child: ListView.builder( itemCount: contributorList?.length, shrinkWrap: true, itemBuilder: (context, index) { @@ -102,11 +106,14 @@ class ContributorsPage extends StatelessWidget { return InkWell( onTap: () { - RouteUtils.toWebViewPage(initialUrl: Uri.parse(contributor.htmlUrl ?? '')); + RouteUtils.toWebViewPage( + initialUrl: + Uri.parse(contributor.htmlUrl ?? '')); }, child: WidgetAnimator( Container( - padding: const EdgeInsets.only(top: 5, bottom: 5, left: 10), + padding: const EdgeInsets.only( + top: 5, bottom: 5, left: 10), child: Row( children: [ SizedBox( @@ -114,7 +121,9 @@ class ContributorsPage extends StatelessWidget { width: 50, child: CachedNetworkImage( imageUrl: contributor.avatarUrl ?? '', - imageBuilder: (context, imageProvider) => CircleAvatar( + imageBuilder: + (context, imageProvider) => + CircleAvatar( radius: 15.0, backgroundImage: imageProvider, ), From d048dd52f23c24fb974fb593bdf7d6929a7a56de Mon Sep 17 00:00:00 2001 From: Location <59411633+James-Lu-none@users.noreply.github.com> Date: Thu, 26 Oct 2023 23:17:42 +0800 Subject: [PATCH 4/4] dart format --- .../pages/other/page/contributors_page.dart | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/lib/ui/pages/other/page/contributors_page.dart b/lib/ui/pages/other/page/contributors_page.dart index 544a4aa0..a890a71b 100644 --- a/lib/ui/pages/other/page/contributors_page.dart +++ b/lib/ui/pages/other/page/contributors_page.dart @@ -12,8 +12,7 @@ import 'package:github/github.dart'; class ContributorsPage extends StatelessWidget { final github = GitHub(); - final repositorySlug = - RepositorySlug(AppLink.githubOwnerName, AppLink.tatRepoName); + final repositorySlug = RepositorySlug(AppLink.githubOwnerName, AppLink.tatRepoName); ContributorsPage({super.key}); @@ -58,8 +57,7 @@ class ContributorsPage extends StatelessWidget { children: [ Text( R.current.github, - style: const TextStyle( - fontWeight: FontWeight.w600), + style: const TextStyle(fontWeight: FontWeight.w600), ) ], ), @@ -91,9 +89,7 @@ class ContributorsPage extends StatelessWidget { ], ), FutureBuilder>( - future: github.repositories - .listContributors(repositorySlug) - .toList(), + future: github.repositories.listContributors(repositorySlug).toList(), builder: (context, snapshot) { if (snapshot.hasData) { final contributorList = snapshot.data; @@ -106,14 +102,11 @@ class ContributorsPage extends StatelessWidget { return InkWell( onTap: () { - RouteUtils.toWebViewPage( - initialUrl: - Uri.parse(contributor.htmlUrl ?? '')); + RouteUtils.toWebViewPage(initialUrl: Uri.parse(contributor.htmlUrl ?? '')); }, child: WidgetAnimator( Container( - padding: const EdgeInsets.only( - top: 5, bottom: 5, left: 10), + padding: const EdgeInsets.only(top: 5, bottom: 5, left: 10), child: Row( children: [ SizedBox( @@ -121,9 +114,7 @@ class ContributorsPage extends StatelessWidget { width: 50, child: CachedNetworkImage( imageUrl: contributor.avatarUrl ?? '', - imageBuilder: - (context, imageProvider) => - CircleAvatar( + imageBuilder: (context, imageProvider) => CircleAvatar( radius: 15.0, backgroundImage: imageProvider, ),