Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
Demonstrates adding and removing items in a shopping cart using FlutterFlow visual elements and Dart state.
import 'package:flutter/material.dart';
class ShoppingCart extends StatefulWidget {
@override
_ShoppingCartState createState() => _ShoppingCartState();
}
class _ShoppingCartState extends State<ShoppingCart> {
final List<String> cart = [];
final TextEditingController controller = TextEditingController();
void addItem(){
if(controller.text.isNotEmpty){
setState(()=>cart.add(controller.text));
controller.clear();
}
}
void removeItem(int i){
setState(()=>cart.removeAt(i));
}
@override
Widget build(BuildContext context){
return Scaffold(
appBar: AppBar(title: Text('Shopping Cart')),
body: Column(children:[
TextField(controller: controller, decoration: InputDecoration(hintText:'Add Item')),
ElevatedButton(onPressed: addItem, child: Text('Add')),
Expanded(child: ListView.builder(
itemCount: cart.length,
itemBuilder: (c,i)=>ListTile(title:Text(cart[i]), trailing: IconButton(icon:Icon(Icons.delete), onPressed:()=>removeItem(i)))
))
])
);
}
}FlutterFlow is a low-code visual app builder that enables users to create native iOS, Android, and web applications using a drag-and-drop interface, powered by Google’s Flutter framework.
Origin & Creator
FlutterFlow was created by Abel Mengistu and Alex Greaves, launched in 2021 to simplify Flutter app development for both developers and non-developers.
Industrial Note
FlutterFlow is popular among startup founders, Flutter developers, and product teams building cross-platform applications rapidly with both visual UI editing and optional custom coding.