survey_form 0.0.1-dev.1 copy "survey_form: ^0.0.1-dev.1" to clipboard
survey_form: ^0.0.1-dev.1 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:survey_form/blocs/app_localization.dart';
import 'package:survey_form/blocs/survey_form_localization_delegate.dart';
import 'package:digit_components/widgets/digit_elevated_button.dart';
import 'package:flutter/material.dart';
import 'package:survey_form/pages/acknowledgement.dart';
import 'package:flutter/services.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:Container(
          width: 300,
          child: DigitElevatedButton(
            child: const Text("Acknowledgement Page"),
            onPressed: () {
              Navigator.of(context).push(
                  MaterialPageRoute(
                      builder: (BuildContext context) => SurveyFormAcknowledgementPage(
                        appLocalizations: SurveyFormLocalization(
                            const Locale("en","MZ"),
                            localizedStrings,
                            languages
                        ),
                      ))
              );
            },
          ),
        ),
      ),
    );
  }
}
0
likes
0
points
245
downloads

Publisher

unverified uploader

Weekly Downloads

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

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

auto_route, build_runner, collection, dart_mappable, digit_components, digit_data_model, 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