Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.4 kB
1
Indexable
Never
import 'package:flutter/material.dart';

class ModalBottom extends StatelessWidget {
  ModalBottom({super.key, required this.addTask});
  final Function addTask;
  String textValue = "";
  void _handleOnclick(BuildContext context) {
    if (textValue.isEmpty) {
      return;
    }
    addTask(textValue);
    Navigator.pop(context);
  }

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: MediaQuery.of(context).viewInsets,
      child: SingleChildScrollView(
          padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 20),
          child: Column(
            children: [
              TextField(
                onChanged: (text) {
                  textValue = text;
                }, //bat su kien nhan gia tri input value
                decoration: const InputDecoration(
                  border: OutlineInputBorder(),
                  labelText: 'Your Task',
                ),
              ),
              const SizedBox(
                height: 20,
              ),
              SizedBox(
                width: double.infinity,
                child: ElevatedButton(
                  onPressed: () => _handleOnclick(context),
                  child: const Text('Add'),
                ),
              )
            ],
          )),
    );
  }
}