formio 0.1.1 copy "formio: ^0.1.1" to clipboard
formio: ^0.1.1 copied to clipboard

A dynamic form rendering and submission package for Flutter using Form.io schemas.

example/lib/main.dart

import 'dart:convert';

import 'package:flutter/material.dart';
import 'package:formio/formio.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        // This is the theme of your application.
        //
        // TRY THIS: Try running your application with "flutter run". You'll see
        // the application has a purple toolbar. Then, without quitting the app,
        // try changing the seedColor in the colorScheme below to Colors.green
        // and then invoke "hot reload" (save your changes or press the "hot
        // reload" button in a Flutter-supported IDE, or press "r" if you used
        // the command line to start the app).
        //
        // Notice that the counter didn't reset back to zero; the application
        // state is not lost during the reload. To reset the state, use hot
        // restart instead.
        //
        // This works for code too, not just values: Most code changes can be
        // tested with just a hot reload.
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});
  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  List<FormModel> forms=[];
  int index=0;
  void initState() {
    ApiClient.setBaseUrl(Uri.parse('https://formio.spinex.io'));
    final formService = FormService(ApiClient());
    formService.fetchForms().then((e){
      forms = e;
      print(forms.length);
      setState(() {
        
      });
    });
    super.initState();
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body:ListView(
        children: [
          Container(
            padding: EdgeInsets.all(20), 
            child: Text('Form Number: ${index+1} of ${forms.length}'),
          ),
          Container(
            padding: EdgeInsets.all(20), 
            child:  forms.isEmpty ? SizedBox() : FormRenderer(form: forms[index],)
          ),
          Container(padding: EdgeInsets.all(20), child: forms.isEmpty ? SizedBox() : Text(forms[index].toJson().toString())),
        ],
      ),
      floatingActionButton: FloatingActionButton(
              onPressed: (){
                if(forms.isNotEmpty && forms.length > index+1){
                  index++;
                }
                setState(() {
                  print(jsonEncode(forms[index]));
                });
              },
              tooltip: 'Increment',
              child: const Icon(Icons.add),
            ), 
    );
  }
}
0
likes
95
points
15
downloads

Publisher

verified publisherspinex.io

Weekly Downloads

A dynamic form rendering and submission package for Flutter using Form.io schemas.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

unknown (license)

Dependencies

dio, file_picker, flutter, flutter_html, intl, provider

More

Packages that depend on formio