v0.4.1
Pre-release
Pre-release
stream_feed
0.4.0+2
Changelog
- fix: export image_storage_client.dart
stream_feed_flutter_core
0.4.1
Changelog
- new: UploadListCore and UploadController
Uploads are at the heart of feeds applications so we made this convenient classes to help you manage the state of media uploads (fail, progress, success, cancel) in your Stream's powered app
Usage :
import 'package:flutter/material.dart';
import 'package:image_picker/image_picker.dart';
import 'package:stream_feed_flutter_core/stream_feed_flutter_core.dart';
....
class ComposeScreen extends StatefulWidget {
const ComposeScreen({Key? key}) : super(key: key);
@override
State<ComposeScreen> createState() => _ComposeScreenState();
}
class _ComposeScreenState extends State<ComposeScreen> {
late AttachmentFile? _file = null;
@override
Widget build(BuildContext context) {
final uploadController = FeedProvider.of(context).bloc.uploadController;
return Scaffold(
appBar: AppBar(title: const Text('Compose'), actions: [
Padding(
padding: const EdgeInsets.all(8.0),
child: ActionChip(
label: const Text(
'Post',
style: TextStyle(
color: Colors.blue,
),
),
backgroundColor: Colors.white,
onPressed: () {
final attachments = uploadController.getMediaUris();
print(attachments);
uploadController.clear();
}),
)
]),
body: SingleChildScrollView(
child: Column(children: [
Padding(
padding: const EdgeInsets.all(8.0),
child: TextField(
decoration: InputDecoration(hintText: "this is a text field"),
),
),
IconButton(
onPressed: () async {
final ImagePicker _picker = ImagePicker();
final XFile? image =
await _picker.pickImage(source: ImageSource.gallery);
if (image != null) {
await FeedProvider.of(context)
.bloc
.uploadController
.uploadImage(AttachmentFile(path: image.path));
} else {
// User canceled the picker
}
},
icon: Icon(Icons.file_copy)),
UploadListCore(
uploadController: FeedProvider.of(context).bloc.uploadController,
uploadsBuilder: (context, uploads) {
return SizedBox(
height: 100,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: uploads.length,
itemBuilder: (context, index) => FileUploadStateWidget(
fileState: uploads[index],
onRemoveUpload: (attachment) {
return uploadController.removeUpload(attachment);
},
onCancelUpload: (attachment) {
uploadController.cancelUpload(attachment);
},
onRetryUpload: (attachment) async {
return uploadController.uploadImage(attachment);
}),
),
);
},
),
])),
);
}
}