survey_form 1.0.1+3 copy "survey_form: ^1.0.1+3" to clipboard
survey_form: ^1.0.1+3 copied to clipboard

This package enables supervisors to monitor certain activities and record observations according to defined set of questions.

example/lib/main.dart

import 'dart:convert';

import 'package:digit_ui_components/digit_components.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:survey_form/blocs/app_localization.dart';
import 'package:survey_form/blocs/survey_form_localization_delegate.dart';
import 'package:survey_form/pages/acknowledgement.dart';

import 'localizedString.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(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Survey Form Package Example'),
    );
  }
}

Future<List> loadLocalizedStrings() async {
  String jsonString = await rootBundle.loadString('lib/data.json');
  // Decode the JSON string
  List<dynamic> jsonList = jsonDecode(jsonString);

  // Convert the dynamic list to a list of LocalizedString objects
  return jsonList
      .map((jsonItem) => LocalizedString.fromJson(jsonItem))
      .toList();
}

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

  final String title;

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

class _MyHomePageState extends State<MyHomePage> {
  late Future<dynamic> localizedStrings;
  final languages = [
    {"label": "PORTUGUÊS", "value": "pt_MZ"},
    {"label": "FRENCH", "value": "fr_MZ"},
    {"label": "ENGLISH", "value": "en_MZ"}
  ];

  @override
  void initState() {
    super.initState();
    localizedStrings = loadLocalizedStrings();

    SurveyFormLocalizationDelegate delegate =
        SurveyFormLocalizationDelegate(localizedStrings, languages);
    delegate.load(const Locale("en", "MZ"));
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Center(
        child: SizedBox(
          width: 300,
          child: DigitButton(
            label: "Acknowledgement Page",
            size: DigitButtonSize.large,
            onPressed: () {
              Navigator.of(context).push(MaterialPageRoute(
                  builder: (BuildContext context) =>
                      SurveyFormAcknowledgementPage(
                        appLocalizations: SurveyFormLocalization(
                            const Locale("en", "MZ"),
                            localizedStrings,
                            languages),
                      )));
            },
            type: DigitButtonType.primary,
          ),
        ),
      ),
    );
  }
}
copied to clipboard
0
likes
110
points
158
downloads

Publisher

unverified uploader

Weekly Downloads

2024.09.16 - 2025.03.31

This package enables supervisors to monitor certain activities and record observations according to defined set of questions.

Homepage
Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

auto_route, collection, dart_mappable, digit_data_model, digit_ui_components, dio, drift, flutter, flutter_bloc, flutter_svg, fluttertoast, freezed_annotation, group_radio_button, intl, location, overlay_builder, reactive_forms

More

Packages that depend on survey_form