form_builder_image_picker 0.1.2 form_builder_image_picker: ^0.1.2 copied to clipboard
Field for picking image(s) from Gallery or Camera for flutter_form_builder package
import 'package:flutter/material.dart';
import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:form_builder_image_picker/form_builder_image_picker.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
final _formKey = GlobalKey<FormBuilderState>();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('FormBuilderImagePicker Example'),
),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: Center(
child: FormBuilder(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
FormBuilderImagePicker(
name: 'photos',
decoration: const InputDecoration(labelText: 'Pick Photos'),
maxImages: 1,
),
const SizedBox(height: 15),
RaisedButton(onPressed: () {
if (_formKey.currentState.saveAndValidate()) {
print(_formKey.currentState.value);
}
})
],
),
),
),
),
);
}
}