Gridview Rectangle, Circle, Clipper In Flutter :

import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { //KITA BERANDAI PUNYA DATA YANG DIDAPATKAN DARI BACKEND DENGAN FORMAT SEPERTI BERIKUT //SEBUAH ARRAY YANG DI DALAMNYA TERDAPAT OBJECT DATA final List<Map<String, dynamic>> _kategori = [ {'cat': 'Flutter', 'color': Colors.pink}, {'cat': 'Laravel', 'color': Colors.blue}, {'cat': 'Vue.js', 'color': Colors.amber}, {'cat': 'Javascript', 'color': Colors.yellow}, {'cat': 'PHP', 'color': Colors.red}, {'cat': 'Java', 'color': Colors.black}, ]; @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar( title: Text('Grid View'), ), body: Container( margin: const EdgeInsets.all(10.0), child: GridView.builder( itemCount: _kategori.length, gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 3, mainAxisSpacing: 3, crossAxisSpacing: 3, childAspectRatio: 1), itemBuilder: (context, index) { return /*Container( color: _kategori[index]['color'], height: 200, child: Center( child: Text(_kategori[index]['cat'], style: TextStyle( color: _kategori[index]['cat'] != 'Javascript' ? Colors.white : Colors.black, fontWeight: FontWeight.bold, ))));*/ /*ClipRRect( borderRadius: BorderRadius.circular(100), child: Container( color: _kategori[index]['color'], height: 200, child: Center( child: Text(_kategori[index]['cat'], style: TextStyle( color: _kategori[index]['cat'] != 'Javascript' ? Colors.white : Colors.black, fontWeight: FontWeight.bold, )))));*/ ClipPath( clipper: ClipperContainer(), child: Container( color: _kategori[index]['color'], height: 200, child: Center( child: Text(_kategori[index]['cat'], style: TextStyle( color: _kategori[index]['cat'] != 'Javascript' ? Colors.white : Colors.black, fontWeight: FontWeight.bold, ))))); })))); } } class ClipperContainer extends CustomClipper<Path> { @override Path getClip(Size size) { var path = Path(); path.lineTo(0, size.height); path.quadraticBezierTo(0, size.width / 2, size.height, size.width); path.lineTo(size.width, 0); path.close(); return path; } @override bool shouldReclip(CustomClipper<Path> oldClipper) => true; }
The flutter tutorial is a website that bring you the latest and amazing resources of code. All the languages codes are included in this website. The languages like flutter, android, java,kotlin etc.with the help of this languages any user can develop the beautiful application
For more information about Flutter. visit www.fluttertutorial.in