Here’s an example of a basic restaurant menu app in Flutter:
import ‘package:flutter/material.dart’;
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: ‘Restaurant Menu App’,
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MenuList(),
);
}
}
class MenuList extends StatefulWidget {
@override
_MenuListState createState() => _MenuListState();
}
class _MenuListState extends State<MenuList> {
List<String> _menuItems = [‘Pizza’, ‘Burger’, ‘Tacos’, ‘Pasta’];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(‘Restaurant Menu’),
),
body: ListView.builder(
itemCount: _menuItems.length,
itemBuilder: (context, index) {
return ListTile(
title: Text(_menuItems[index]),
);
},
),
);
}
}
In this example, a MenuList
widget is created which extends StatefulWidget
. The state of the widget is managed by _MenuListState
. The _menuItems
list stores the menu items. The UI consists of a list of the menu items, which is displayed using a ListView.builder
. The user can see all of the items on the menu by scrolling through the list. You can add more functionality like adding images and descriptions to each menu item, or adding a detail screen for each menu item.