Skip to content

Instantly share code, notes, and snippets.

@viveky259259
Last active September 30, 2019 14:25
Show Gist options
  • Save viveky259259/d2d1cf17dca2272132cffbce4de21dbd to your computer and use it in GitHub Desktop.
Save viveky259259/d2d1cf17dca2272132cffbce4de21dbd to your computer and use it in GitHub Desktop.
NoteUi File
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