Last active
September 30, 2019 14:25
-
-
Save viveky259259/d2d1cf17dca2272132cffbce4de21dbd to your computer and use it in GitHub Desktop.
NoteUi File
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:flutter_bloc/flutter_bloc.dart'; | |
import 'package:flutter_for_people/bloc/notes/note.bloc.dart'; | |
import 'package:flutter_for_people/bloc/notes/note.state.dart'; | |
class NotesUi extends StatefulWidget { | |
@override | |
_NotesUiState createState() => _NotesUiState(); | |
} | |
class _NotesUiState extends State<NotesUi> { | |
@override | |
Widget build(BuildContext context) { | |
final NoteBloc noteBloc = BlocProvider.of<NoteBloc>(context); | |
return Scaffold( | |
appBar: AppBar( | |
title: Text("Notes"), | |
), | |
body: BlocBuilder<NoteBloc, NoteState>( | |
bloc: noteBloc, | |
builder: (BuildContext context, NoteState state) { | |
if (state is InitialNoteState) { | |
return Center( | |
child: Text('Welcome to notes family'), | |
); | |
} else if (state is FetchingNoteCompleteState) { | |
return ListView.builder( | |
shrinkWrap: true, | |
itemCount: state.notes.length, | |
itemBuilder: (context, index) { | |
return Text(state.notes[index].toString()); | |
}, | |
); | |
} | |
return Center(child: Text("Notes app home page")); | |
}, | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment