0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Flutter webでfooterを実装する方法

Posted at
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('CustomScrollView'),
      ),
      body: CustomScrollView( // ⇦ ここ
        slivers: [
          SliverToBoxAdapter(
            child: Column(
              children: [
                Container(
                  height: 200,
                  color: Colors.blue,
                ),
                Container(height: 100, color: Colors.cyan)
              ],
            ),
          ),
          SliverFillRemaining( // ⇦ ここ
            hasScrollBody: false, // ⇦ ここ
            child: Column(
              children: [
                const Spacer(), // ⇦ ここ
                Container(
                  width: double.infinity,
                  child: const Center(child: Text("This is Footer")),
                  decoration: BoxDecoration(
                    border: Border.all(color: Colors.black26, width: 1),
                  ),
                )
              ],
            ),
          )
        ],
      ),
    );
  }
}

Feb-12-2022 15-53-45.gif

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?