class Note {
final String title;
final String description;
Note({this.title, this.description});
}
class NotesBloc extends Bloc<NotesEvent, NotesState> {
final _notes = List<Note>();
@override
NotesState get initialState => NotesLoaded(_notes);
@override
Stream<NotesState> mapEventToState(NotesEvent event) async* {
if (event is AddNote) {
_notes.add(event.note);
yield NotesLoaded(_notes);
} else if (event is DeleteNote) {
_notes.remove(event.note);
yield NotesLoaded(_notes);
}
}
}
abstract class NotesEvent extends Equatable {
const NotesEvent();
}
class AddNote extends NotesEvent {
final Note note;
const AddNote(this.note);
@override
List<Object> get props => [note];
}
class DeleteNote extends NotesEvent {
final Note note;
const DeleteNote(this.note);
@override
List<Object> get props => [note];
}
abstract class NotesState extends Equatable {
const NotesState();
}
class NotesLoaded extends NotesState {
final List<Note> notes;
const NotesLoaded(this.notes);
@override
List<Object> get props => [notes];
}
class NotesScreen extends StatefulWidget {
@override
_NotesScreenState createState() => _NotesScreenState();
}
class _NotesScreenState extends State<NotesScreen> {
final _bloc = NotesBloc();
@override
Widget build(BuildContext context) {
return BlocProvider(
create: (context) => _bloc,
child: Scaffold(
appBar: AppBar(
title: Text('Notes'),
),
body: BlocBuilder<NotesBloc, NotesState>(
builder: (context, state) {
if (state is NotesLoaded) {
return ListView.builder(
itemCount: state.notes.length,
itemBuilder: (context, index) {
final note = state.notes[index];
return ListTile(
title: Text(note.title),
subtitle: Text(note.description),
trailing: IconButton(
icon: Icon(Icons.delete),
onPressed: () {
context.bloc<NotesBloc>().add(DeleteNote(note));
},
),
);
},
);
}
return Center(
child: CircularProgressIndicator(),
);
},
),
floatingActionButton: FloatingActionButton(
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => AddNoteScreen(),
),
);
},
child: Icon(Icons.add),
),
),
);
}
}
class AddNoteScreen extends StatefulWidget {
@override
_AddNoteScreenState createState() => _AddNoteScreenState();
}
class _AddNoteScreenState extends State<AddNoteScreen> {
final _formKey = GlobalKey<FormState>();
final _titleController = TextEditingController();
final _descriptionController = TextEditingController();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Add Note'),
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Form(
key: _formKey,
child: Column(
children: [
TextFormField(
controller: _titleController,
decoration: InputDecoration(labelText: 'Title'),
validator: (value) {
if (value.isEmpty) {
return 'Please enter a title';
}
return null;
},
),
TextFormField(
controller: _descriptionController,
decoration: InputDecoration(labelText: 'Description'),
validator: (value) {
if (value.isEmpty) {
return 'Please enter a description';
}
return null;
},
),
RaisedButton(
onPressed: () {
if (_formKey.currentState.validate()) {
final note = Note(
title: _titleController.text,
description: _descriptionController.text,
);
context.bloc<NotesBloc>().add(AddNote(note));
Navigator.of(context).pop();
}
},
child: Text('Add'),
),
],
),
),
),
);
}
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Notes'),
),
body: BlocBuilder<NotesBloc, NotesState>(
builder: (context, state) {
if (state is NotesLoaded) {
return ListView.builder(
itemCount: state.notes.length,
itemBuilder: (context, index) {
final note = state.notes[index];
return ListTile(
title: Text(note.title),
subtitle: Text(note.description),
trailing: IconButton(
icon: Icon(Icons.delete),
onPressed: () {
context.bloc<NotesBloc>().add(DeleteNote(note));
},
),
);
},
);
}
return Center(
child: CircularProgressIndicator(),
);
},
),
floatingActionButton: FloatingActionButton(
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => AddNoteScreen(),
),
);
},
child: Icon(Icons.add),
),
);
}
facebook.com'a bir talepte bulunduğunuzda, bilgisayarınız o bağlantıyı kurabilmesi için bu alan adını bir IP adresine çevirmek üzere alan adını arar.
Turo, konukların güvenilir ev sahiplerinden oluşan canlı bir topluluktan istedikleri arabayı istedikleri yerde rezerve edebilecekleri dünyanın en büyük araba paylaşım pazarıdır. Turo'daki geliştiriciler yakın zamanda Android uygulamasının başlangıç performansını iyileştirmek için büyük yatırımlar yaptı.
Hayden, birlikte geçirdikleri akşamdan sonra Katie'yi üniversite yurduna geri götürdüğünde gece yarısını geçmişti. Sabah erkenden dersi vardı ve önceki gece onunla kaldıktan sonra bir daha kıyafet değiştirmedi.
Günümüzün hızlı tempolu ve rekabetçi dünyasında, kişinin kariyeri kişisel gelişim, finansal istikrar ve genel yaşam memnuniyetinde önemli bir rol oynamaktadır. Bununla birlikte, birçok kişi profesyonel yaşamlarında giderek tükenmekte olan amansız bir durgunluk ve tatminsizlik döngüsüne kapılmış durumda.
Merhaba, siber meraklıları! Tehdit avı için OSINT serisine tekrar hoş geldiniz. İlk makalede, size OSINT'e genel bir bakış ve onun tehdit avlamadaki önemi hakkında bilgi verdim.
[Tetik uyarısı: Bu makale, Jordan Neely'nin katilini öven insanların ekran görüntülerini içerir.] Kolluk kuvvetleri nihayet - ve belki de isteksizce - Jordan Neely'yi ölene kadar boğan Daniel Penny'yi bu cinayetle suçladı.