커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
4-9 책 상세 페이지 WebView로 보기 중 초기 설정에서 에러가 납니다. 똑같이 따라하고 있는데 왜일까요?
앱개발 종합반 - 플러터 v8
4주차
북마크
김*강
댓글
7
추천
0
조회수
13
조회수
13
답변 완료

ㅗ* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.

* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.


Webview 설치를 위해 터미널에서 실행 및 pubspec.yaml에 추가된 것은 확인 했습니다.

강의 내용 중 android -> app-> build.gradle 에서 버전을 19로 수정하라고 해서 수정도 했습니다.

그런데 이상하게 build.gradle에서 error1개가 발생하구요 (라인 11, GradleException 에 빨간 줄(G 대문자 밑에요)이 생기고 quick fix도 업습니다.

그리고 mail.dart에서 2개의 error가 발생 합니다.

새로 추가한 widget (line 194 ~ line 207) 에서 발생된 에러는 quick fix로 수정할 수 있다고 하시는데 저한태는 그 옵션이 나타나지 않습니다.





스파르타 즉문즉답


스파르타 즉문즉답




build.gradle code
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}


def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
    throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}


def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
    flutterVersionCode = '1'
}


def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
    flutterVersionName = '1.0'
}


apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"


android {
    namespace "com.example.watch_pedia"
    compileSdkVersion flutter.compileSdkVersion
    ndkVersion flutter.ndkVersion


    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }


    kotlinOptions {
        jvmTarget = '1.8'
    }


    sourceSets {
        main.java.srcDirs += 'src/main/kotlin'
    }


    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "com.example.watch_pedia"
        // You can update the following values to match your application needs.
        // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration.
        minSdkVersion 19
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }


    buildTypes {
        release {
            // TODO: Add your own signing config for the release build.
            // Signing with the debug keys for now, so `flutter run --release` works.
            signingConfig signingConfigs.debug
        }
    }
}


flutter {
    source '../..'
}


dependencies {
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

main.dart code

import 'package:flutter/material.dart';

import 'package:provider/provider.dart';


import 'book.dart';

import 'book_service.dart';


void main() {

  runApp(

    MultiProvider(

      providers: [

        ChangeNotifierProvider(create: (context) => BookService()),

      ],

      child: const MyApp(),

    ),

  );

}


class MyApp extends StatelessWidget {

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


  @override

  Widget build(BuildContext context) {

    return MaterialApp(

      debugShowCheckedModeBanner: false,

      home: HomePage(),

    );

  }

}


class HomePage extends StatefulWidget {

  HomePage({Key? key}) : super(key: key);


  @override

  State<HomePage> createState() => _HomePageState();

}


class _HomePageState extends State<HomePage> {

  var bottomNavIndex = 0;

  @override

  Widget build(BuildContext context) {

    return Scaffold(

      body: [

        SearchPage(),

        LikedBookPage(),

      ].elementAt(bottomNavIndex),

      bottomNavigationBar: BottomNavigationBar(

        selectedItemColor: Colors.black,

        unselectedItemColor: Colors.grey,

        showUnselectedLabels: true,

        selectedFontSize: 12,

        unselectedFontSize: 12,

        iconSize: 28,

        type: BottomNavigationBarType.fixed,

        onTap: (value) {

          setState(() {

            bottomNavIndex = value;

          });

        },

        items: [

          BottomNavigationBarItem(

            icon: Icon(Icons.search),

            label: '검색',

          ),

          BottomNavigationBarItem(

            icon: Icon(Icons.star),

            label: '좋아요',

          ),

        ],

        currentIndex: bottomNavIndex,

      ),

    );

  }

}


class SearchPage extends StatelessWidget {

  SearchPage({super.key});


  @override

  Widget build(BuildContext context) {

    return Consumer<BookService>(

      builder: (context, bookService, child) {

        return Scaffold(

          appBar: AppBar(

            backgroundColor: Colors.white,

            toolbarHeight: 80,

            title: TextField(

              onSubmitted: (value) {

                bookService.search(value);

              },

              cursorColor: Colors.grey,

              decoration: InputDecoration(

                prefixIcon: Icon(Icons.search, color: Colors.grey),

                hintText: "작품, 감독, 배우, 컬렉션, 유저 등",

                border: OutlineInputBorder(

                  borderSide: BorderSide(color: Colors.white),

                  borderRadius: BorderRadius.all(Radius.circular(10)),

                ),

                focusedBorder: OutlineInputBorder(

                  borderSide: BorderSide(color: Colors.grey),

                  borderRadius: BorderRadius.all(Radius.circular(10)),

                ),

              ),

            ),

          ),

          body: Padding(

            padding: const EdgeInsets.symmetric(horizontal: 12),

            child: ListView.separated(

              itemCount: bookService.bookList.length,

              separatorBuilder: (context, index) {

                return Divider();

              },

              itemBuilder: (context, index) {

                if (bookService.bookList.isEmpty) return SizedBox();

                Book book = bookService.bookList.elementAt(index);

                return bookTile(book: book);

              },

            ),

          ),

        );

      },

    );

  }

}


class bookTile extends StatelessWidget {

  const bookTile({

    super.key,

    required this.book,

  });


  final Book book;


  @override

  Widget build(BuildContext context) {

    BookService bookService = context.read<BookService>();


    return ListTile(

      onTap: () {},

      leading: Image.network(

        book.thumbnail,

        fit: BoxFit.fitHeight,

      ),

      title: Text(

        book.title,

        style: TextStyle(fontSize: 16),

      ),

      subtitle: Text(

        book.subtitle,

        style: TextStyle(color: Colors.grey),

      ),

      trailing: IconButton(

        onPressed: () {

          bookService.toggleLikeBook(book: book);

        },

        icon: bookService.likedBookList.map((book) => book.id).contains(book.id)

            ? Icon(

                Icons.star,

                color: Colors.amber,

              )

            : Icon(Icons.star_border),

      ),

    );

  }

}


class LikedBookPage extends StatelessWidget {

  const LikedBookPage({super.key});


  @override

  Widget build(BuildContext context) {

    return Consumer<BookService>(

      builder: (context, bookService, child) {

        return Scaffold(

          body: Padding(

            padding: const EdgeInsets.symmetric(horizontal: 12),

            child: ListView.separated(

              itemCount: bookService.likedBookList.length,

              separatorBuilder: (context, index) {

                return Divider();

              },

              itemBuilder: (context, index) {

                if (bookService.likedBookList.isEmpty) return SizedBox();

                Book book = bookService.likedBookList.elementAt(index);

                return bookTile(book: book);

              },

            ),

          ),

        );

      },

    );

  }

}


class WebViewPage extends StatelessWidget {

  WebViewPage({super.key, required this.url});


  String url;


  @override

  Widget build(BuildContext context) {

    return Scaffold(

      appBar: AppBar(

        backgroundColor: Colors.grey,

        title: Text(url),

      ),

      body: WebView(initialUrl: url),

    );

  }

}


취소
 공유
취소
댓글 0
댓글 알림
나의얼굴