Untitled
unknown
plain_text
2 years ago
3.2 kB
3
Indexable
import 'package:flutter/material.dart'; import 'package:flutter_application_1/models/items.dart'; import 'package:flutter_application_1/widget/card_body.dart'; import 'widget/modal_bottom.dart'; void main() { // runApp(const MaterialApp( // home: Text('Hello Word'), // )); // runApp(const MaterialApp( // home: Scaffold( // body: Text('Hello Word') // ), // )); runApp(const MaterialApp( debugShowCheckedModeBanner: false, home: MyWidget(), )); } class MyWidget extends StatefulWidget { const MyWidget({super.key}); @override State<MyWidget> createState() => _MyWidgetState(); } class _MyWidgetState extends State<MyWidget> { final List<DataItems> items = []; void _handleAddTask(String name) { final newItem = DataItems(id: DateTime.now().toString(), name: name); setState(() { items.add(newItem); }); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Center( child: Text( 'Tieu de ne', style: TextStyle( color: Colors.white, fontSize: 50, ), ), ), ), body: SingleChildScrollView( padding: const EdgeInsets.symmetric(vertical: 20, horizontal: 20), child: Column( children: items.map((item) => CardBody(item: item)).toList(), ), ), floatingActionButton: FloatingActionButton( onPressed: () { showModalBottomSheet( backgroundColor: Colors.grey, shape: const RoundedRectangleBorder( borderRadius: BorderRadius.vertical(top: Radius.circular(20))), isScrollControlled: true, //Khi open keyboard no se day form nhap len tren , ko bi chen` ep context: context, builder: (BuildContext content) { return ModalBottom(addTask: _handleAddTask); }); }, child: const Icon( Icons.add, size: 40, ), ), ); } } // class MyWidget extends StatelessWidget { // final bool loading; // const MyWidget(this.loading, {super.key}); // @override // Widget build(BuildContext context) { // return loading // ? const CircularProgressIndicator() // : const Text("thong bao"); // } // } // class MyWidget2 extends StatefulWidget { // final bool loading; // const MyWidget2(this.loading, {super.key}); // @override // State<StatefulWidget> createState() { // return MyWidget2State(); // } // } // class MyWidget2State extends State<MyWidget2> { // late bool _localLoading; // @override // void initState() { // _localLoading = widget.loading; // } // @override // Widget build(BuildContext context) { // return _localLoading // ? const CircularProgressIndicator() // : FloatingActionButton(onPressed: onClick); // } // void onClick() { // setState(() { // _localLoading = true; // }); // } // }
Editor is loading...