Paki ayos ang mali sa code
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_colorpicker/flutter_colorpicker.dart';
class ColorPalettePage extends StatefulWidget {
final bool isDarkModeEnabled;
const ColorPalettePage({required this.isDarkModeEnabled});
Override
_ColorPalettePageState createState() => _ColorPalettePageState();
}
class _ColorPalettePageState extends State<ColorPalettePage> {
Color pickerColor = Color(0xff443a49);
Color currentColor = Color(0xff443a49);
Override
Widget build(BuildContext context) {
return MaterialApp(
theme: widget.isDarkModeEnabled ? ThemeData.dark() : ThemeData.light(),
home: Builder(
builder: (BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Color Palette'),
backgroundColor: Colors.deepPurple,
),
final MaterialColor primarySwatch = MaterialColor(currentColor.value, {
50: currentColor.withOpacity(0.1),
100: currentColor.withOpacity(0.2),
200: currentColor.withOpacity(0.3),
300: currentColor.withOpacity(0.4),
400: currentColor.withOpacity(0.5),
500: currentColor.withOpacity(0.6),
600: currentColor.withOpacity(0.7),
700: currentColor.withOpacity(0.8),
800: currentColor.withOpacity(0.9),
900: currentColor.withOpacity(1),
});
body: SingleChildScrollView(
child: Column(
children: List.generate(
5,
(rowIndex) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: List.generate(
2,
(colIndex) {
final index = rowIndex * 2 + colIndex + 1; // Start from 1
// Calculate the shade of red for each container
final Color? color = primarySwatch[index * 100];
return Padding(
padding: EdgeInsets.fromLTRB(2, 10, 2, 10), // Add margin
child: Container(
width: 190.0,
height: 180.0,
decoration: BoxDecoration(
color: Colors.grey,
borderRadius: BorderRadius.circular(10.0), // Add borderRadius
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: Offset(0, 3),
),
],
),
child: Stack(
children: [
Align(
alignment: Alignment.bottomLeft,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(
'$index',
style: TextStyle(
color: Colors.black,fontSize: 20
),
),
),
),
const Align(
alignment: Alignment.bottomRight,
child: Padding(
padding: EdgeInsets.all(8.0),
child: Icon(
Icons.content_copy,
color: Colors.black,
),
),
),
Container(
margin: const EdgeInsets.fromLTRB(0, 0, 0, 50),
width: double.infinity,
height: 220,
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
color: color,
boxShadow: const [
BoxShadow(
color: Color(0x3f000000),
offset: Offset(0, 0),
blurRadius: 2,
),
BoxShadow(
color: Color(0x3f000000),
offset: Offset(0, 5),
blurRadius: 2,
),
],
),
),
],
),
),
);
},
),
);
},
),
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: const Text('Pick a color!'),
content: SingleChildScrollView(
child: Column(
children: [
BlockPicker(
pickerColor: pickerColor,
onColorChanged: changeColor,
),
ElevatedButton(
onPressed: () {
setState(() {
currentColor = pickerColor;
});
Navigator.of(context).pop();
},
child: Text('Select'),
),
],
),
),
);
},
);
},
backgroundColor: Colors.white,
child: Padding(
padding: const EdgeInsets.all(5),
child: Image.asset('assets/square icon.png'),
),
),
floatingActionButtonLocation: FloatingActionButtonLocation.endFloat,
);
},
),
);
}
void changeColor(Color color) {
setState(() {
pickerColor = color;
});
}
}