1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Flutterでよく使うテンプレ(View関係)

Last updated at Posted at 2024-06-06

右上のDEBUGを消す

MaterialApp(
      debugShowCheckedModeBanner: false,
      ...

AppBarの設定

 AppBar(
    backgroundColor: Color.fromARGB(246, 228, 228, 228), //背景色
    elevation: 0, //影
    leading: IconButton(onPressed: (){}, icon: const Icon(Icons.menu)),
),

全体の背景色

Scaffold(
      backgroundColor: const Color.fromARGB(246, 228, 228, 228),
      ...

FloatingActionButtonの設定

floatingActionButton: FloatingActionButton(
    onPressed: (){},
    backgroundColor: Colors.white, //背景色
    child: const Icon(Icons.add, color: Colors.black,), 
),

ページ遷移

Navigator.push(context, MaterialPageRoute(builder: (context)=> NewPage()));

riverpod関係

main.dart

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:shelf/view/home_page.dart';

void main() {
  runApp(
    ProviderScope(child: MyApp())
  );
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: HomePage(), //最初に表示されるページ
    );
  }
}

final hogesProvider = StateProvider<List<hoge>>((ref)=> []);
class Hoge extends StateNotifier{
  Ref ref;

  Hoge({required this.ref}) : super(null);

}

※自分はよくこの形で使ってるけど、実際どういう使い方が多いのだろうか?

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?