5 Widget
unknown
dart
2 months ago
2.1 kB
1
Indexable
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( debugShowCheckedModeBanner: false, title: 'Flutter Multi AppBar with Spacing', theme: ThemeData( colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue), useMaterial3: true, ), home: const MyHomePage(), ); } } class MyHomePage extends StatelessWidget { const MyHomePage({super.key}); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: const Text('Main AppBar'), backgroundColor: Colors.blue, // Warna AppBar utama ), body: Column( children: [ const SizedBox(height: 10), // Jarak sebelum AppBar 1 _buildAppBar('Aslam', Colors.red), const SizedBox(height: 10), // Jarak antar AppBar _buildAppBar('Haqqan', Colors.green), const SizedBox(height: 10), _buildAppBar('Albin', Colors.blue), const SizedBox(height: 10), _buildAppBar('Faqih', Colors.orange), const SizedBox(height: 10), _buildAppBar('Afirus', Colors.purple), const SizedBox(height: 20), // Jarak sebelum konten utama const Expanded( child: Center( child: Text( 'Ini adalah konten utama', style: TextStyle(fontSize: 20), ), ), ), ], ), ); } // Fungsi untuk membuat AppBar tambahan Widget _buildAppBar(String title, Color color) { return Container( height: 50, width: double.infinity, color: color, child: Center( child: Text( title, style: const TextStyle( color: Colors.white, fontSize: 18, fontWeight: FontWeight.bold, ), ), ), ); } }
Editor is loading...
Leave a Comment