Advertisement
Dman_14

Passing Idea list

Jan 28th, 2021
880
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.43 KB | None | 0 0
  1. class IdeasMainPage extends StatelessWidget {
  2.   @override
  3.   Widget build(BuildContext context) {
  4.     return BaseView<IdeasMainPageController>(onControllerReady: (controller) {
  5.       controller.initialize();
  6.     }, builder: (context, controller, child) {
  7.       return Scaffold(
  8.         backgroundColor: Colors.white.withOpacity(0.9),
  9.         appBar: AppBar(
  10.           title: Text('Ideas'),
  11.         ),
  12.         floatingActionButton: FloatingActionButton(
  13.           onPressed: () {
  14.             Navigator.push(
  15.                 context,
  16.                 MaterialPageRoute(
  17.                     builder: (context) => CreateIdeaPage('Create Idea')));
  18.           },
  19.           child: Icon(Icons.add),
  20.         ),
  21.         body: controller.ideas.isEmpty
  22.             ? NoIdeas()
  23.             : IdeasList(
  24.                 ideas: controller.ideas,
  25.               ),
  26.       );
  27.     });
  28.   }
  29. }
  30.  
  31. class IdeasList extends StatelessWidget {
  32.   final List<Idea> ideas;
  33.   const IdeasList({Key key, this.ideas}) : super(key: key);
  34.  
  35.   @override
  36.   Widget build(BuildContext context) {
  37.     return ListView.builder(
  38.         itemCount: ideas.length,
  39.         itemBuilder: (context, index) {
  40.           return IdeaCard(
  41.             idea: ideas[index],
  42.           );
  43.         });
  44.   }
  45. }
  46.  
  47. class NoIdeas extends StatelessWidget {
  48.   const NoIdeas({Key key}) : super(key: key);
  49.  
  50.   @override
  51.   Widget build(BuildContext context) {
  52.     return Container();
  53.   }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement