LCOV - code coverage report
Current view: top level - lib/projects/widgets/grid-view - create_project_form.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 1 24 4.2 %
Date: 2022-03-03 12:16:13 Functions: 0 0 -

          Line data    Source code
       1             : import 'package:flutter/material.dart';
       2             : 
       3             : import '../../../utils/build_context_extensions.dart';
       4             : import '../../actions/create_project_action.dart';
       5             : import '../../actions/update_projects_view_action.dart';
       6             : import '../../models/project_model.dart';
       7             : 
       8             : class CreateProjectForm extends StatefulWidget {
       9           1 :   const CreateProjectForm({Key? key}) : super(key: key);
      10             : 
      11           0 :   @override
      12             :   CreateProjectFormState createState() {
      13           0 :     return CreateProjectFormState();
      14             :   }
      15             : }
      16             : 
      17             : class CreateProjectFormState extends State<CreateProjectForm> {
      18             :   // Create a global key that uniquely identifies the Form widget
      19             :   // and allows validation of the form.
      20             :   //
      21             :   // The GlobalKey type parameter is FormState, not CreateProjectFormState.
      22             :   final _formKey = GlobalKey<FormState>();
      23             : 
      24             :   final _controller = TextEditingController();
      25             : 
      26           0 :   @override
      27             :   Widget build(BuildContext context) {
      28             :     // Build a Form widget using the _formKey created above.
      29           0 :     return Form(
      30           0 :       key: _formKey,
      31           0 :       child: Column(
      32             :         crossAxisAlignment: CrossAxisAlignment.start,
      33           0 :         children: [
      34           0 :           TextFormField(
      35           0 :             controller: _controller,
      36             :             // The validator receives the text that the user has entered.
      37           0 :             validator: (value) {
      38           0 :               if (value == null || value.isEmpty) {
      39             :                 return 'Please enter some text';
      40             :               }
      41             :               return null;
      42             :             },
      43             :           ),
      44           0 :           Row(
      45           0 :             children: [
      46           0 :               Padding(
      47             :                 padding: const EdgeInsets.symmetric(vertical: 16.0),
      48           0 :                 child: ElevatedButton(
      49           0 :                   onPressed: () {
      50           0 :                     if (_formKey.currentState!.validate()) {
      51           0 :                       context.dispatch(CreateProjectAction(
      52           0 :                           ProjectModel.init(name: _controller.text)));
      53             :                     }
      54             :                   },
      55             :                   child: const Text('Submit'),
      56             :                 ),
      57             :               ),
      58           0 :               Padding(
      59             :                 padding: const EdgeInsets.symmetric(vertical: 16.0),
      60           0 :                 child: ElevatedButton(
      61           0 :                   onPressed: () {
      62           0 :                     context.dispatch(
      63             :                         const UpdateProjectsViewAction(creating: false));
      64             :                   },
      65             :                   child: const Text('Cancel'),
      66             :                 ),
      67             :               ),
      68             :             ],
      69             :           ),
      70             :         ],
      71             :       ),
      72             :     );
      73             :   }
      74             : }

Generated by: LCOV version 1.13