Флэттер: верхняя область каркасов не навязывается на iOSIOS

Программируем под IOS
Ответить Пред. темаСлед. тема
Anonymous
 Флэттер: верхняя область каркасов не навязывается на iOS

Сообщение Anonymous »

edit: < /strong>
Это происходит только на iOS < /p>
Я не могу нажать на виджет, когда он расположен в верхней части каркаса. Эта проблема возникает в версии Flutter 3.24.3 на стабильном канале и версии 3.32.0-1.0.pre.427 на главном канале. В настоящее время я должен добавить верхнюю панель, чтобы сделать кнопку подборной, но это приводит к тому, что мой пользовательский интерфейс отличается от дизайна. Что -то может привлечь в верхней части экрана < /li>
< /ol>
Пример кода < /p>
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';

void main() {
runApp(AppMain());
}

class AppMain extends StatefulWidget {
AppMain({super.key});

@override
State createState() => _AppMainState();
}

class _AppMainState extends State {
@override
Widget build(BuildContext context) {
return MaterialApp(
routes: {
ExtractArgumentsScreen.routeName: (context) => const ExtractArgumentsScreen(),
},
onGenerateRoute: (settings) {
if (settings.name == PassArgumentsScreen.routeName) {
final args = settings.arguments as ScreenArguments;

return MaterialPageRoute(
builder: (context) {
return PassArgumentsScreen(
title: args.title,
message: args.message,
);
},
);
}
assert(false, 'Need to implement ${settings.name}');
return null;
},
builder: (context, child) {
return Column(
children: [
Material(
child: SafeArea(
bottom: false,
child: Container(
padding: EdgeInsets.all(8),
width: double.infinity,
color: Color(0xffff5290),
child: Center(
child: Text(
"This is a banner This is a banner",
style: TextStyle(color: Colors.white, fontWeight: FontWeight.bold, fontSize: 14),
),
),
),
),
),
Expanded(child: child ?? Container())
],
);
},
title: 'Navigation with Arguments',
home: const HomeScreenA(),
);
}
}

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

@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: false,
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.start,
children: [
ElevatedButton(
style: ButtonStyle(
backgroundColor: WidgetStateProperty.all(Colors.red),
),
onPressed: () {
Navigator.pushNamed(
context,
ExtractArgumentsScreen.routeName,
arguments: ScreenArguments(
'Extract Arguments Screen',
'This message is extracted in the build method.',
),
);
},
child: const Text('Navigate to screen that extracts arguments', style: TextStyle(color: Colors.white),),
),
ElevatedButton(
style: ButtonStyle(
backgroundColor: WidgetStateProperty.all(Colors.green),
),
onPressed: () {
Navigator.pushNamed(
context,
PassArgumentsScreen.routeName,
arguments: ScreenArguments(
'Accept Arguments Screen',
'This message is extracted in the onGenerateRoute '
'function.',
),
);
},
child: const Text('Navigate to a named that accepts arguments', style: TextStyle(color: Colors.white)),
),
],
),
),
);
}
}

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

static const routeName = '/extractArguments';

@override
Widget build(BuildContext context) {
final args = ModalRoute.of(context)!.settings.arguments as ScreenArguments;

return Scaffold(
appBar: AppBar(title: Text(args.title)),
body: Center(child: Text(args.message)),
);
}
}

class PassArgumentsScreen extends StatelessWidget {
static const routeName = '/passArguments';

final String title;
final String message;

const PassArgumentsScreen({
super.key,
required this.title,
required this.message,
});

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text(title)),
body: Center(child: Text(message)),
);
}
}

class ScreenArguments {
final String title;
final String message;

ScreenArguments(this.title, this.message);
}

экрановоды:

my flutter doctor
[!] Flutter (Channel master, 3.32.0-1.0.pre.427, on macOS 14.6.1 23G93 darwin-arm64, locale en-US) [7.3s]
• Flutter version 3.32.0-1.0.pre.427 on channel master at /Users/lap15759/Documents/src/flutter
! Warning: `dart` on your path resolves to /opt/homebrew/Cellar/dart/3.4.4/libexec/bin/dart, which is not inside your current Flutter SDK checkout at /Users/lap15759/Documents/src/flutter. Consider adding /Users/lap15759/Documents/src/flutter/bin to the front of your path.
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision a3a41226e5 (17 hours ago), 2025-05-06 06:19:27 -0400
• Engine revision a3a41226e5
• Dart version 3.9.0 (build 3.9.0-97.0.dev)
• DevTools version 2.46.0-dev.0
• If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [5.3s]
• Android SDK at /Users/lap15759/Library/Android/sdk
• Emulator version 35.3.11.0 (build_id 12836668) (CL:N/A)
• Platform android-35, build-tools 35.0.0
• Java binary at: /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home/bin/java
This JDK is specified in your Flutter configuration.
To change the current JDK, run: `flutter config --jdk-dir="path/to/jdk"`.
• Java version OpenJDK Runtime Environment Temurin-17.0.14+7 (build 17.0.14+7)
• All Android licenses accepted.

[!] Xcode - develop for iOS and macOS (Xcode 16.2) [5.3s]
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 16C5032a
! CocoaPods 1.15.2 out of date (1.16.2 is recommended).
CocoaPods is a package manager for iOS or macOS platform code.
Without CocoaPods, plugins will not work on iOS or macOS.
For more info, see https://flutter.dev/to/platform-plugins
To update CocoaPods, see https://guides.cocoapods.org/using/gett ... -cocoapods

[✓] Chrome - develop for the web [10ms]
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.2) [9ms]
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 21.0.3+-79915917-b509.11)

[✓] Connected device (3 available) [8.4s]
• iPhone 16 Pro (mobile) • E1624697-9FC3-49F1-B11C-776704F6DBD4 • ios • com.apple.CoreSimulator.SimRuntime.iOS-18-2 (simulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 14.6.1 23G93 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 135.0.7049.116

[✓] Network resources [490ms]
• All expected network resources are available.

! Doctor found issues in 2 categories.
Process finished with exit code 0


Подробнее здесь: https://stackoverflow.com/questions/796 ... ble-on-ios
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «IOS»