floating_action_button.1.dart 1.14 KB
Newer Older
1 2 3 4 5 6
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/material.dart';

7 8 9
/// Flutter code sample for [FloatingActionButton].

void main() => runApp(const FloatingActionButtonExampleApp());
10

11 12
class FloatingActionButtonExampleApp extends StatelessWidget {
  const FloatingActionButtonExampleApp({super.key});
13 14 15 16

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
17
      home: FabExample(),
18 19 20 21
    );
  }
}

22
class FabExample extends StatelessWidget {
23
  const FabExample({super.key});
24 25 26 27 28

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
29
        title: const Text('FloatingActionButton Sample'),
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
      ),
      body: const Center(
        child: Text('Press the button with a label below!'),
      ),
      floatingActionButton: FloatingActionButton.extended(
        onPressed: () {
          // Add your onPressed code here!
        },
        label: const Text('Approve'),
        icon: const Icon(Icons.thumb_up),
        backgroundColor: Colors.pink,
      ),
    );
  }
}