defined. нужен child а компилятор ругаеться,решение предлагают очистить кэш проекта,но думаю ошибка больше в синтаксисе
import 'package:flutter/material.dart';
class CaseScheduler extends StatefulWidget {
const CaseScheduler({Key? key}) : super(key: key);
@override
State<CaseScheduler> createState() => _CaseSchedulerState();
}
class _CaseSchedulerState extends State<CaseScheduler> {
List<String> _cases = [
"Case 1",
"Case 2",
"Case 3",
"Case 4",
"Case 5",
"Case 6",
"Case 7",
"Case 8",
"Case 9",
"Case 10",
];
String _selectedCase = "Case 1";
String _selectedDay = "Day 1";
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Case Scheduler"),
),
backgroundColor: const Color(0xffc8e9f1),
body: Column(
children: [
DropdownButton<String>(
value: _selectedDay,
hint: const Text("Select a day"),
items: <String>[
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday'
].map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
onChanged: (String? value) {
setState(() {
_selectedDay = value!;
});
},
),
Expanded(
child: GridView.builder(
gridDelegate:
const SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
),
itemCount: _cases.length,
itemBuilder: (BuildContext context, int index) {
return GestureDetector(
onTap: () {
setState(() {
_selectedCase = _cases[index];
});
},
child: Container(
margin: const EdgeInsets.all(10),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
color: _selectedCase == _cases[index]
? Colors.blue
: const Color(0xffc8e9f1),
),
child: Center(
child: Text(
_cases[index],
style: TextStyle(
color: _selectedCase == _cases[index]
? Colors.white
: Colors.yellow,),
child: Center(
child: Text(
_cases[index],
style: TextStyle(
color: _selectedCase == _cases[index]
? Colors.white
: Colors.yellow,
),
),
),
),
),
),);
},
),
),
ElevatedButton(
onPressed: _selectedCase == null
? null
: () {
// Add selected case to schedule
print("Added $_selectedCase to schedule for $_selectedDay");
},
child: const Text("Add to schedule"),
),
],
),
);
}
}
Ты предлагаешь в сообщении отсчитать 85 строк ?
Обсуждают сегодня