int getDaysInMonth(DateTime date) {
DateTime firstDayOfNextMonth = (date.month < 12)
? DateTime(date.year, date.month + 1, 1)
: DateTime(date.year + 1, 1, 1);
//проблема у тебя была тут. Ты сам у себя сьел 1 день
DateTime lastDayOfMonth = firstDayOfNextMonth.subtract(Duration(seconds: 1));
return lastDayOfMonth.day;
}
void main() {
DateTime date = DateTime(2024, 3, 1); // Пример: 1 марта 2024 года
int daysInMonth = getDaysInMonth(date);
print("Количество дней в месяце: $daysInMonth");
}
abstract class Model {
List<String> getFields();
}
class Data extends Model {
late final int field1;
late final int field2;
Data({required this.field1, required this.field2});
@override
List<String> getFields() {
return ["field1", "field2"];
}
}
class Table<T extends Model> {
final List<T> dataList;
late List<String> fieldList;
Table({required this.dataList, required T instance}) {
if (dataList.isEmpty) {
fieldList = instance.getFields();
} else {
fieldList = dataList.first.getFields();
}
}
}
import 'package:flutter/material.dart';
import 'package:flutter_/style.dart';
class Registration extends StatefulWidget {
@override
State<Registration> createState() => _Registration();
}
class _Registration extends State<Registration> {
final _nameController = TextEditingController();
final _passwordController = TextEditingController();
Widget button(text, linc) {
return ElevatedButton(
style: ElevatedButton.styleFrom(
primary: s.buttonColor, minimumSize: Size(2500, 70)),
onPressed: () {
Navigator.pushNamed(context, linc);
submitForm();
},
child: Text("${text}", style: TextStyle(color: Colors.white)),
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: s.backgroundColor,
appBar: AppBar(
centerTitle: true,
backgroundColor: s.appBarColor,
title: Text("Регистрация", style: TextStyle(color: Colors.white)),
),
body: Center(
child: Container(
padding: EdgeInsets.symmetric(horizontal: 100, vertical: 100),
child: Column(
children: [
Icon(
Icons.watch_later,
color: s.buttonColor,
size: 150,
),
SizedBox(
height: 50,
),
TextFormField(
controller: _nameController,
decoration: InputDecoration(labelText: "Имя пользователя"),
),
TextFormField(
controller: _passwordController,
decoration: InputDecoration(labelText: "Пароль"),
),
SizedBox(
height: 50,
),
button("Зарегистрироваться", "/home_page_schedule")
],
)),
));
}
void submitForm() {
print("Name ${_nameController.text}");
}
}