Created
June 21, 2025 21:01
-
-
Save Beyarz/9fbcb7d6d5db70ccd2c4a9200f600603 to your computer and use it in GitHub Desktop.
Dart.dev Shopping list example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:flutter/material.dart'; | |
| void main() => runApp(const MyApp()); | |
| class MyApp extends StatelessWidget { | |
| const MyApp({super.key}); | |
| @override | |
| Widget build(BuildContext context) { | |
| return MaterialApp( | |
| title: 'Shopping App', | |
| debugShowCheckedModeBanner: false, | |
| theme: ThemeData( | |
| colorSchemeSeed: const Color.fromRGBO(90, 133, 233, 1), | |
| tabBarTheme: const TabBarThemeData( | |
| labelColor: Colors.white, | |
| unselectedLabelColor: Colors.white70, | |
| indicator: null, | |
| indicatorColor: Colors.white, | |
| indicatorSize: TabBarIndicatorSize.tab, | |
| ), | |
| ), | |
| home: const ShoppingScreen(), | |
| ); | |
| } | |
| } | |
| class ShoppingScreen extends StatefulWidget { | |
| const ShoppingScreen({super.key}); | |
| @override | |
| State<ShoppingScreen> createState() => _ShoppingScreenState(); | |
| } | |
| class _ShoppingScreenState extends State<ShoppingScreen> | |
| with SingleTickerProviderStateMixin { | |
| late final TabController _tabController; | |
| final List<String> _tabs = const ['Shoes', 'Pants', 'Shirts', 'Outlet']; | |
| @override | |
| void initState() { | |
| super.initState(); | |
| _tabController = TabController(length: _tabs.length, vsync: this); | |
| } | |
| @override | |
| void dispose() { | |
| _tabController.dispose(); | |
| super.dispose(); | |
| } | |
| @override | |
| Widget build(BuildContext context) { | |
| return Scaffold( | |
| appBar: AppBar( | |
| title: const Text( | |
| 'Shopping', | |
| style: TextStyle(color: Colors.white), | |
| ), | |
| backgroundColor: const Color.fromRGBO(90, 133, 233, 1), | |
| bottom: TabBar( | |
| controller: _tabController, | |
| indicatorWeight: 4.0, | |
| tabs: _tabs.map<Widget>((String tabName) { | |
| return Tab(text: tabName); | |
| }).toList(), | |
| ), | |
| ), | |
| body: TabBarView( | |
| controller: _tabController, | |
| children: _tabs.map<Widget>((String tabName) { | |
| return Container( | |
| color: const Color.fromRGBO(60, 90, 150, 1), | |
| ); | |
| }).toList(), | |
| ), | |
| ); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment