Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- import 'package:nb_utils/nb_utils.dart';
- class ChipsTakingFood extends StatefulWidget {
- final List<String> values;
- final int initialPosition;
- final Function(int index) onSelected;
- ChipsTakingFood(
- {required this.values,
- required this.onSelected,
- this.initialPosition = 0});
- @override
- _RadioChipsState createState() => _RadioChipsState();
- }
- class _RadioChipsState extends State<ChipsTakingFood> {
- late int current;
- @override
- void initState() {
- super.initState();
- current = widget.initialPosition;
- }
- @override
- Widget build(BuildContext context) {
- Size size = MediaQuery.of(context).size;
- return Container(
- height: size.height / 15,
- width: size.width / 1,
- alignment: Alignment.center,
- decoration: boxDecorationWithRoundedCorners(
- //backgroundColor: Color(0xFF463E44),
- borderRadius: BorderRadius.circular(0),
- ),
- child: Row(
- mainAxisSize: MainAxisSize.min,
- crossAxisAlignment: CrossAxisAlignment.center,
- children: List.generate(
- widget.values.length,
- (index) {
- return GestureDetector(
- onTap: () async {
- setState(() => current = index);
- widget.onSelected(index);
- },
- child: Container(
- height: size.height / 15,
- width: size.width / 3.5,
- alignment: Alignment.center,
- margin: const EdgeInsets.symmetric(horizontal: 4),
- padding: const EdgeInsets.symmetric(horizontal: 20),
- decoration: BoxDecoration(
- borderRadius: const BorderRadius.all(Radius.circular(15)),
- color:
- index == current ? Color(0xFF71B24D) : Colors.grey[400],
- ),
- child: Column(
- mainAxisAlignment: MainAxisAlignment.center,
- children: [
- Icon(
- Icons.breakfast_dining_outlined,
- color: Colors.white,
- ).visible(index == 0),
- Icon(
- Icons.ramen_dining_outlined,
- color: Colors.white,
- ).visible(index == 1),
- Icon(
- Icons.dinner_dining_outlined,
- color: Colors.white,
- ).visible(index == 2),
- Text(widget.values[index],
- style: TextStyle(
- color: Colors.white, fontFamily: 'Comfortaa')),
- ],
- ),
- ),
- );
- },
- ),
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement