android – flutter net : Once I picture add to storage, I can not management the standard of the picture picker

0
49


The sdk that I take advantage of is as follows.

  sdk: ">=2.7.0 <3.0.0"
  image_picker: ^0.6.7 
  image_picker_for_web: ^0.1.0
  firebase_storage: ^3.1.6
  cloud_firestore: ^0.13.7

When importing a picture to storage, I attempt to scale back the dimensions of the picture file.
And that is the code for picture add.

import 'package deal:image_picker/image_picker.dart';
import 'package deal:firebase/firebase.dart' as fb;
import 'package deal:omd_test/widget/custom_loading.dart';

class TestScreen extends StatefulWidget {
  @override
  State<TestScreen> createState() => _TestScreenState();
}

class _TestScreenState extends State<TestScreen> {
  PickedFile _image;
  String imageUrl;

  @override
  Widget construct(BuildContext context) {
    return SafeArea(
      baby: Padding(
        padding: const EdgeInsets.all(8.0),
        baby: Scaffold(
          appBar: AppBar(
            title: Textual content("TEST"),
          ),

          physique: Padding(
            padding: const EdgeInsets.all(12.0),
            baby: Column(
              youngsters: [
                Container(
                    width: 200,
                    height: 200,
                    child: _image == null
                        ? Container()
                        : Image.network(
                            _image.path,
                          )),
                TextButton(
                    onPressed: () {
                      _getImagesPicker();
                    },
                    child: Text(
                      "Pick",
                      style: TextStyle(color: Colors.black),
                    )),
                SizedBox(
                  height: 20,
                ),
                TextButton(
                    onPressed: () async {
                      if (_image != null) {
                        await imageUpload(_image);

                        setState(() {
                          _image = null;
                        });

                      } else
                        print("No Image");
                    },
                    child: Text(
                      "Upload"
                    )),
              ],
            ),
          ),
        ),
      ),
    );
  }

  Future<void> _getImagesPicker() async {
    attempt {
      ultimate _imagePath = await ImagePicker().getImage(
          supply: ImageSource.gallery,
          imageQuality: 10,
          maxHeight: 50,
          maxWidth: 50
      );
      setState(() {
        _image = _imagePath;
      });
    } catch (err) {
      print(err);
    }
  }

  Future<String> imageUpload(PickedFile picture) async {
    var bytes = await picture.readAsBytes();

    fb.StorageReference _storage =
        fb.storage().ref('testScreen/${picture.path}.jpg');
    fb.UploadTaskSnapshot uploadTaskSnapshot = await _storage
        .put(bytes, fb.UploadMetadata(contentType: 'picture/png'))
        .future;

    var imageUri = await uploadTaskSnapshot.ref.getDownloadURL();
    imageUrl = imageUri.toString();
    return imageUrl;
  }
}

I examined by altering the worth of ‘imageQuality’ of ImagePicker, however when uploaded to storage, all picture recordsdata have been the identical measurement.

enter picture description right here

Can I do know what the issue is?
Is it an issue to add to storage?

Thanks.