떨림을 추가할 수 없습 제목에 AppBarTheme

0

질문

나는 작업에 떨림 프로젝트와 나도 추가 title 매개 변수 AppBarTheme 하지만 그것이 나에게 오류가 있습니다. 이 코드:

@override
Widget build(BuildContext context){
  return MaterialApp(
    theme: ThemeData(
      primarySwatch: Colors.green,
      accentColor: Colors.pinkAccent,
      fontFamily: 'Quicksand',
      appBarTheme: 
        AppBarTheme(textTheme: ThemeData.light().textTheme.copyWith(
          title: const TextStyle(
            fontFamily: 'Quicksand',
            fontSize: 20,
            )
          )
        )
      )
    );
  }

이 오류는 다음과 같습니다: The named parameter 'title' isn't defined. 어떻게 해결할 수 있는 이?

dart flutter
2021-11-24 00:20:01
2

최고의 응답

2

여기에는 방법:

import 'package:flutter/material.dart';

class Home extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('AppBar titleTextStyle')),
      body: Center(child: Text('Hello World')),
    );
  }
}

void main() {
  runApp(
    MaterialApp(
      theme: ThemeData.light().copyWith(
        appBarTheme: AppBarTheme(
          backgroundColor: Colors.yellow,
          titleTextStyle: TextStyle(color: Colors.black),
          backwardsCompatibility: false, // !!!
        ),
      ),
      home: Home(),
    ),
  );
}
2021-11-25 00:49:57
0

할 수 없습니다 추가 제목을 AppBarTheme,당신을 제공 할 수 있 TextStyle 제목에서 themeData 추가 제목에서 AppBar 다음과 같다:

AppBar(
    title: Text(
      'your text',
      // You need to add this line
      style: Theme.of(context).appBarTheme.TextStyle,
    ),
),
2021-11-24 04:22:52

다른 언어로

이 페이지는 다른 언어로되어 있습니다

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
हिन्दी
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................