Code Monkey home page Code Monkey logo

flutter_platform_widgets's People

Contributors

abahnj avatar ahawlitschek avatar aqwert avatar bookshiyi avatar dabenzel avatar dfelten avatar ericmartineau avatar eyecreate avatar fbernutz avatar fdwl avatar fredgrott avatar furkantektas avatar gem85247 avatar hanskokx avatar in74mz avatar josxha avatar kiruel avatar kishormainali avatar koningjasper avatar lance-dev avatar mhaid avatar mlava avatar nathanfallet avatar onyekachisamuel avatar patricknicolosi avatar rledisez avatar sck-v avatar stefanrusek avatar trietbui85 avatar yoann-tyt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flutter_platform_widgets's Issues

Manually select platform

Hi

Is there anyway to manually select the platform ? so that PlatformScaffold and other platform-related widgets display the correct widget

I don't have a mac laptop and want to debug my ios-style app on my android then compile it on a mac device

Navigator.pop returns a black screen on Alert Dialog

Hi

I use this code to show a dialog to user

showDialog(
        context: context,
        builder: (_) => PlatformAlertDialog(
          title: Text('Alert'),
          content: Text('Some content'),
          actions: <Widget>[
            PlatformDialogAction(
              child: PlatformText('OK'),
              onPressed: () => Navigator.pop(context),
            ),
          ],
        ));

But after tapping on OK , a black screen shows.
It works well with default dialog ( below code )

showDialog(
        context: context,
        builder: (context) {
          return Center(
              child: AlertDialog(
                title: new Text("Alert Dialog title"),
                content: new Text("Alert Dialog body"),
                actions: <Widget>[
                  // usually buttons at the bottom of the dialog
                  new FlatButton(
                    child: new Text("Close"),
                    onPressed: () {
                      Navigator.of(context).pop();
                    },
                  ),
                ],
              ));
        });

any help

[Question] Multiple heroes share the same tag within a subtree

Hello,
I was trying to implement your package into my little architecture app. App

I get this error on iOS:

The following assertion was thrown during a scheduler callback:
There are multiple heroes that share the same tag within a subtree.

I assume there is some Platform Widget that is complaining about keys. Not really sure where to start looking. Do you have any advice?

PlatformScaffold padding works only for AppBar

Using iosContentPadding: true, is not giving padding from the bottom, so PlatformNavBar lays over the body:

return PlatformScaffold(
  appBar: PlatformAppBar(...),
  body: Flex(...),
  bottomNavBar: PlatformNavBar(...),
  iosContentPadding: true,
);

PlatformListTile Suggestion

I'm just starting to play with Flutter, and was slightly disappointed in the non-native UI on iOS without duplicating the UI widgets by default, so thanks for the work on this package!

As mentioned in your Known Issues section, ListTile is one of the widgets that requires a Material widget somewhere in the hierarchy (who knows why ListTile is inside Material when ListView is not. Another issue is the Ink touch animation built into ListTile which is also not native to iOS. I had some ideas on possible solutions:

  1. Create a CupertinoListTile inside flutter_platform_widgets (maybe flutter will include it in the future). This could be used from a PlatformListTile widget for iOS, which could also automatically wrap that tile in a Material widget.

What I don't like about that is every tile will have an extra Material Widget.

  1. A second option which is similar would be to again have a CupertinoListTile widget as part of this package, but also include a PlatformListView. On iOS this could return a Material widget as a wrapper around the whole Listview on iOS, so only one extra widget is generated.

Either of these would also allow the InkWell splash animation to be disabled via this method for iOS.

I'm too new to Dart/Flutter to suggest implementing myself, but would be happy to contribute in other ways (testing/documentation) if it would help.

Missing platform widgets

Are you going to implement the missing widgets like Checkbox, Radio, Slider, etc.? Or is it better to implement ourselves?
Thanks.

Can't copy into focussed PlatformTextField

At least on the Android version of PlatformTextField it is not possible to copy text into the text field if the text field is already in focus (which also means that if autofocus: true is set it is never possible to copy text into the field). This is best reproducible by either typing something in, removing it, and then trying to copy in text or by simply using the autofocus: true property.

CupertinoTabScaffold multiple pages

Whenever you set a bottomNavBar on ios, the CupertinoPageScaffold creates a CupertinoTabScaffold, but its tabBuilder recreates a new CupertinoPageScaffold on each tab click without using the index argument, so it just basically duplicates the body, making the nav bar useless.
Any idea on how to handle ios navigation ? a callback inside CupertinoPageScaffoldData ?
thanks

Is this production ready?

Can this be used in an actual project?

If not, is there an ETA of when this is possible or is this just a proof of concept? And secondly, does it not work when building an app or would it perform just fine?

In my opinion, Flutter should support this logic out of the box so I'm kinda surprised it wasn't.

BottomNavBar for only iOS is impossible

Currently it's not possible to generate an iOS app with a bottom nav bar and and Android app without one.

This was the code I tested:

PlatformScaffold(
  appBar: PlatformAppBar(title: PlatformText('TEST', ),),
  ios: (context) => CupertinoPageScaffoldData(
      bottomTabBar: CupertinoTabBar(
      items: <BottomNavigationBarItem>[
          BottomNavigationBarItem(
              title: PlatformText("Feed"),
              icon: Icon(Icons.subject),
           ),
          BottomNavigationBarItem(
              title: PlatformText("Settings"),
              icon: Icon(Icons.settings),
          ),
       ],
  )),
  body: Container(),
);

Bug: Wrong Padding in PlatformScaffold

In order to decided whether padding is necessary or not, the fullObstruction is used.
It is defined the following (Cupertino):

bool get fullObstruction => backgroundColor.alpha == 0xFF;

When looking inside the PlatformScaffold there is the following code:

if (!navigationBar.fullObstruction) { var pad = Padding( padding: EdgeInsets.only(top: topPadding), child: child, ); child = pad; }

Padding is added, if the bar is is not fullObstruction => When alpha != 0xFF.
This means padding is added when we want a nav bar where the user could look through.
Removing the ! fixes the issue.

The following NoSuchMethodError was thrown building PlatformScaffold(dirty):

I/flutter (13031): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (13031): The following NoSuchMethodError was thrown building PlatformScaffold(dirty):
I/flutter (13031): The method '>' was called on null.
I/flutter (13031): Receiver: null
I/flutter (13031): Tried calling: >(0)
I/flutter (13031):
I/flutter (13031): When the exception was thrown, this was the stack:
I/flutter (13031): #0 Object.noSuchMethod (dart:core-patch/object_patch.dart:50:5)
I/flutter (13031): #1 int.< (dart:core-patch/integers.dart:84:18)
I/flutter (13031): #2 int.<= (dart:core-patch/integers.dart:99:37)
I/flutter (13031): #3 new BottomNavigationBar (package:flutter/src/material/bottom_navigation_bar.dart:196:17)
I/flutter (13031): #4 PlatformNavBar.createAndroidWidget (package:flutter_platform_widgets/src/platform_nav_bar.dart:148:15)
I/flutter (13031): #5 PlatformScaffold.createAndroidWidget (package:flutter_platform_widgets/src/platform_scaffold.dart:136:47)
I/flutter (13031): #6 PlatformWidgetBase.build (package:flutter_platform_widgets/src/widget_base.dart:21:14)
I/flutter (13031): #7 StatelessElement.build (package:flutter/src/widgets/framework.dart:3974:28)
I/flutter (13031): #8 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3924:15)
I/flutter (13031): #9 Element.rebuild (package:flutter/src/widgets/framework.dart:3721:5)
I/flutter (13031): #10 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3907:5)
I/flutter (13031): #11 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3902:5)
I/flutter (13031): #12 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3084:14)
I/flutter (13031): #13 Element.updateChild (package:flutter/src/widgets/framework.dart:2887:12)
I/flutter (13031): #14 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3935:16)
I/flutter (13031): #15 Element.rebuild (package:flutter/src/widgets/framework.dart:3721:5)
I/flutter (13031): #16 ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3907:5)
I/flutter (13031): #17 StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:4053:11)
I/flutter (13031): #18 ComponentElement.mount (package:flutter/src/widgets/framework.dart:3902:5)
I/flutter (13031): #19 Element.inflateWidget (package:flutter/src/widgets/framework.dart:3084:14)
I/flutter (13031): #20 Element.updateChild (package:flutter/src/widgets/framework.dart:2887:12)
I/flutter (13031): #21 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3935:16)
I/flutter (13031): #22 Element.rebuild (package:flutter/src/widgets/framework.dart:3721:5)
I/flutter (13031): #23 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2340:33)
I/flutter (13031): #24 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:700:20)
I/flutter (13031): #25 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:285:5)
I/flutter (13031): #26 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1016:15)
I/flutter (13031): #27 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:958:9)
I/flutter (13031): #28 _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:874:5)
I/flutter (13031): #32 _invoke (dart:ui/hooks.dart:236:10)
I/flutter (13031): #33 _drawFrame (dart:ui/hooks.dart:194:3)
I/flutter (13031): (elided 3 frames from package dart:async)

PlatformDialogAction iOS text color

In Android the color of the text is the same as the primary color, but on iOS it stay blue. For me make sens that it take also the primary color for the text as iOS offer natively the tintColor to change that text. Because in 99% we want to get rid of this blue text to put our own color

why initstate() is called multiple times in stateful widget when we use platform widgets?

if we combine platform widget with PlatformNavBar,after we switch from tab1 to tab2, initstate() nitstate() is called multiple times!!! Really a big issue !
`
return PlatformNavBar(
currentIndex: _selectedTabIndex,

  itemChanged: (int index) {
    setState(() {
      _selectedTabIndex = index;
    });
  },
  items: [
    BottomNavigationBarItem(
        icon: Icon(Icons.home),
        title: Text('home')
    ),
    BottomNavigationBarItem(
        icon: Icon(Icons.search),
        title: Text('search')
    ),
    BottomNavigationBarItem(
        icon: Icon(Icons.shopping_cart),
        title: Text('shopping_cart')
    ),


  ],
);`

Where are the Docs?

This library looks great. I am wondering where the docs are for using this library? Or, when we can expect them.

PlatformTextField keyboardType parameter is ignored.

I'm unable to set keyboardType (like TextInputType.number) on PlatformTextField widget. Though, I can successfully set it by defining ios and android parameters, separately.

I think there is a copy & paste mistake in platform_text_field.dart:265.

keyboardType: data?.keyboardType ?? keyboardAppearance,

version: 0.8.1

PlatformAppBar has no bottom named value

The normal AppBar has a bottom

Scaffold(
          appBar: AppBar(
            bottom: TabBar(
              tabs: <Widget>[
                Tab(child: Text('1')),
                Tab(child: Text('2')),
              ],
            ),
          ),

The PlatformAppBar does not have a bottom

PlatformScaffold(
          appBar: PlatformAppBar(
            bottom: TabBar(
              tabs: <Widget>[
                Tab(child: Text('1')),
                Tab(child: Text('2')),
              ],
            ),

Is the missing bottom named value on purpose?

drawer

any chance i am able to use drawer and end drawer. support for multi platform

PlatformScaffold: tabs on top for Android?

Recently we've started working on a few apps in Flutter, using PlatformWidgets as the base for our UI;
however, when exploring the UX patterns for iOS and Android, we've realized that the PlatformScaffold does not really behave in a platform-aware way, as in:

Different sections on Android are organized as tabs on top of the app. Sections are organized as tabs on the bottom of the app on iOS.

(source: https://medium.com/@vedantha/interaction-design-patterns-ios-vs-android-111055f8a9b7)

At this point, we're wondering whether bottomNavBar shouldn't actually be a tabBar that would be automatically placed on the top in Android and on the bottom in iOS?

We've already started working on an implementation of this for our app, I can submit a PR more than gladly.

Change `android` and `ios` property names to `material` and `cupertino`

Especially now in the future where Flutter is also coming to web and desktop, it's perhaps better to rename all enhancment properties to the more neutral material and cupertino, just like the types which are given there (MaterialAppBarData for example).

final appBar = PlatformAppBar(
  title: ..,
  automaticallyImplyLeading: false,
  material: (_) => MaterialAppBarData(..),
  cupertino: (_) => CupertinoNavigationBarData(..)
);

This would obviously be a breaking change (major version has to be increased), but would be better. Especially if you'd make it configurable which theme is used on what platform (another issue entirely of course).

I'd be willing to do this for you by the way in a PR.

SafeArea:top=true results in extra top padding when using solid bgColor for CupertinoNavigationBarData

Continuation from the fixed bug of #15

If you have a SafeArea in your Scaffold body, a solid bgColor in the CupertinoNavigationBarData will still result in too much padding between the bar and the body content.

Below is the code to show. I've set variables named solidNav and safeTop that will trigger whether or not the bar is solid colored or translucent and whether the safearea applies to the top param or not.

import 'package:flutter/material.dart';
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';

void main() => runApp(MyApp());

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

class Test extends StatefulWidget {

  Test({Key key}) :
        super(key: key);

  @override
  _TestState createState() => _TestState();
}

class _TestState extends State<Test> {

  bool solidNav = true;
  bool safeTop = true;

  @override
  Widget build(BuildContext context) {

    return PlatformScaffold(
      appBar: _buildAppBar(),
      body: _buildBody(),
    );
  }

  Widget _buildAppBar() {
    return PlatformAppBar(
      title: Text("test",
        style: Theme.of(context).textTheme.title.copyWith(
          color: solidNav ? Colors.white : Colors.black,
        ),
      ),
      ios: (BuildContext context) => _buildAppBariOS(),
    );
  }


  CupertinoNavigationBarData _buildAppBariOS() {
    return CupertinoNavigationBarData(
      backgroundColor: solidNav ? Colors.black : null,
    );
  }

  Widget _buildBody(){
    return SafeArea(
      top: safeTop,
      child: Container(
        color: Colors.grey,
        child: Center(
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.center,
            children: <Widget>[
              RaisedButton(
                child: Text("Solid navbar with SafeArea:top=false"),
                onPressed: (){
                  setState(() {
                    solidNav = true;
                    safeTop = false;
                  });
                },
              ),
              RaisedButton(
                child: Text("Solid navbar with SafeArea:top=true"),
                onPressed: (){
                  setState(() {
                    solidNav = true;
                    safeTop = true;
                  });
                },
              ),
              RaisedButton(
                child: Text("Translucent navbar with SafeArea:top=true"),
                onPressed: (){
                  setState(() {
                    solidNav = false;
                    safeTop = true;
                  });
                },
              ),
            ],
          ),
        ),
      ),
    );
  }


}


0000

Undefined class CupertinoThemeData

I was trying to run the example app but got this error:

error: Undefined class 'CupertinoThemeData'. (undefined_class at [example] example.dart:30)

info: The library 'package:flutter/cupertino.dart' doesn't export a member with the shown name 'CupertinoThemeData'. (undefined_shown_name at [example] example.dart:1)

Switch Platform Question

This issue is slightly related with #21. I was recently working on a university project and decided to use platform_widgets for easier cross platform support. I decided to implement a separate settings screen and add a change platform button under dev settings. However upon implementing that every time platform was changed I was navigating back to the main screen. As I understand changeToCupertinoPlatform() should be used in the beginning of the app but is there a way to do that and have the changes propagate in the root widget once the back button in the settings screen is pressed rather than jumping directly back?

Solid background color for CupertinoNavigationBarData results in extra top padding

If you set the backgroundColor property on CupertinoNavigationBarData the body of the PlatformScaffold will too much top padding (perhaps doubling the safe area top?)

I made a test where you can swap between translucent (the default) and solid bg colors and see the bug.

Here's the code:

import 'package:flutter/material.dart';
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';

void main() => runApp(MyApp());

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

class Test extends StatefulWidget {

  Test({Key key}) :
        super(key: key);

  @override
  _TestState createState() => _TestState();
}

class _TestState extends State<Test> {

  bool solidNav = false;

  @override
  Widget build(BuildContext context) {
    return PlatformScaffold(
      appBar: _buildAppBar(),
      body: _buildBody(),
    );
  }

  Widget _buildAppBar() {
    return PlatformAppBar(
      title: Text("test",
        style: Theme.of(context).textTheme.title.copyWith(
          color: solidNav ? Colors.white : Colors.black,
        ),
      ),
      ios: (BuildContext context) => _buildAppBariOS(),
    );
  }


  CupertinoNavigationBarData _buildAppBariOS() {
    return CupertinoNavigationBarData(
      backgroundColor: solidNav ? Colors.black : null,
    );
  }

  Widget _buildBody(){
    return SafeArea(
      child: Center(
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: <Widget>[
            RaisedButton(
              child: Text("Solid navbar"),
              onPressed: (){
                setState(() {
                  solidNav = true;
                });
              },
            ),
            RaisedButton(
              child: Text("Translucent navbar"),
              onPressed: (){
                setState(() {
                  solidNav = false;
                });
              },
            ),
          ],
        ),
      ),
    );
  }
}

Flutter doctor:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v0.11.3, on Mac OS X 10.13.6 17G65, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
[✓] Android Studio (version 3.2)
[✓] VS Code (version 1.28.2)
[✓] Connected device (2 available)

• No issues found!

Cupertino "edge swipe" bug

Here is how to reproduce:

  • Run the example code
  • Switch platform to Cupertino
  • Open tabbed page
  • Select the Book tab
  • Swipe from the left edge (back gesture)

Here is the error log:
I/flutter (23115): The following assertion was thrown while handling a gesture:
I/flutter (23115): There are multiple heroes that share the same tag within a subtree.
I/flutter (23115): Within each subtree for which heroes are to be animated (i.e. a PageRoute subtree), each Hero must
I/flutter (23115): have a unique non-null tag.
I/flutter (23115): In this case, multiple heroes had the following tag: Default Hero tag for Cupertino navigation bars
I/flutter (23115): with navigator NavigatorState#174ca(tickers: tracking 2 tickers)
...

PlatformAlertDialog on Android: No named parameter with the name 'contentTextStyle'.

When using PlatformAlertDialog on Android the AlertDialog constructor throws errors because the Parameter "contentTextStyle" does not exist on the constructor.

showPlatformDialog(
          context: context,
          builder: (context) => PlatformAlertDialog(
                title: Text('The title'),
                content: Text('The content'),
                actions: <Widget>[
                  PlatformDialogAction(
                    onPressed: () => Navigator.of(context).pop(false),
                    child: Text('Abort'),
                  ),
                  PlatformDialogAction(
                    onPressed: () => Navigator.of(context).pop(true),
                    child: Text('OK'),
                  ),
                ],
              ),
        )

This error appears:
I/flutter ( 7198): Another exception was thrown: 'package:flutter_platform_widgets/src/platform_alert_dialog.dart': error: line 104 pos 9: file:///E:/dev/sdk/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_platform_widgets-0.9.5/lib/src/platform_alert_dialog.dart:104:9: Error: No named parameter with the name 'contentTextStyle'.

This is because contentTextStyle (as well as backgroundColor, elevation and shape don't exist on the constructor.

Form fields?

Hey there, excellent work with this. I'm writing a Flutter app now and it's just what I need.

I was wondering if you've considered implementing iOS style form fields or if that's too complex? I ask because the main challenge I have is how iOS treats validation, where there's real built in way to show validation error messages next to the iOS form field, one usually shows a UIAlert for any errors.

Any thoughts on that?

Anyway to hook up platform detection to Android Studio's "Toggle Platform Mode"

Android Studio has a button in the Flutter Inspector to toggle the platform between Android and iOS in the same emulator. Just seems to trigger a page rebuild which changes the result of Theme.of(context).platform between TargetPlatform.android and TargetPlatform.iOS.

It seems like your platform.dart triggers off a lower level check against sky_engine/lib/io/platform.dart's Platform. Between isAndroid and isIOS.

I know you have nice methods changeToMaterialPlatform and changeToCupertinoPlatform, but is there any way to tie the auto detection into the Theme's platform so that when I toggled the platform in Android Studio it also toggled the widgets provided by this package?

Thanks.

Application locking up when i navigate to another screen

Thanks for creating this package, super useful for wanting to have an iPhone app look like an iPhone app. I've been converting the first app tutorial to use this package, but navigating to the second screen locks up on me. Either before navigating, or after.

import 'package:flutter/material.dart';
import 'package:english_words/english_words.dart';
import 'package:flutter_platform_widgets/flutter_platform_widgets.dart' as pf;

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return pf.PlatformApp(title: 'Startup name generator', home: RandomWords());
  }
}

class RandomWordsState extends State<RandomWords> {
  final _suggestions = <WordPair>[];
  final _biggerFont = const TextStyle(fontSize: 16.0);
  final _saved = Set<WordPair>();
  @override
  Widget build(BuildContext context) {
    return pf.PlatformScaffold(
      appBar: pf.PlatformAppBar(
          title: Text('Startup name generator'),
          trailingActions: <Widget>[
            IconButton(
              icon: Icon(Icons.list),
              onPressed: _pushSaved,
            )
          ]),
      body: _buildSuggestion(),
    );
  }

  void _pushSaved() {
    Navigator.of(context)
        .push(pf.platformPageRoute(builder: (BuildContext context) {
      final Iterable<ListTile> tiles = _saved.map((WordPair pair) {
        return ListTile(title: Text(pair.asPascalCase, style: _biggerFont));
      });

      final List<Widget> divided =
          ListTile.divideTiles(context: context, tiles: tiles).toList();

      return pf.PlatformScaffold(
        appBar: pf.PlatformAppBar(title: Text('Saved Suggestions')),
        body: ListView(children: divided),
      );
    }));
  }

  Widget _buildSuggestion() {
    return ListView.builder(
      padding: const EdgeInsets.all(16.0),
      itemBuilder: (context, i) {
        if (i.isOdd) return Divider();

        final index = i ~/ 2;
        if (index >= _suggestions.length) {
          _suggestions.addAll(generateWordPairs().take(10));
        }

        return _buildRow(_suggestions[index]);
      },
    );
  }

  Widget _buildRow(WordPair pair) {
    final alreadySaved = _saved.contains(pair);
    return ListTile(
      title: Text(pair.asPascalCase, style: _biggerFont),
      trailing: MySwitch(
          value: alreadySaved,
          toggle: (value) {
            setState(() {
              if (value) {
                _saved.add(pair);
              } else {
                _saved.remove(pair);
              }
            });
          }),
    );
  }
}

class RandomWords extends StatefulWidget {
  @override
  RandomWordsState createState() => RandomWordsState();
}

class MySwitch extends StatelessWidget {
  final bool value;
  final void Function(bool) toggle;

  const MySwitch({
    @required this.value,
    @required this.toggle,
    Key key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return pf.PlatformSwitch(
        value: value,
        onChanged: (alreadySaved) {
          toggle(alreadySaved);
        });
  }
}

Sorry for asking a support question on here, but i haven't had much luck on stackoverflow

Support for Desktop

Flutter is now officially supporting desktop app. You can currently run flutter run -d macos on the master branch of flutter.

Windows and Linux Platform should display Android/Material.

Mac Target Should display Cupertino.

Here is how we set it in the main.dart of the example or app we are running.

void main() {
  // Desktop platforms aren't a valid platform.
  _setTargetPlatformForDesktop();

  return runApp(MyApp());
}

/// If the current platform is desktop, override the default platform to
/// a supported platform (iOS for macOS, Android for Linux and Windows).
/// Otherwise, do nothing.
void _setTargetPlatformForDesktop() {
  TargetPlatform targetPlatform;
  if (Platform.isMacOS) {
    targetPlatform = TargetPlatform.iOS;
  } else if (Platform.isLinux || Platform.isWindows) {
    targetPlatform = TargetPlatform.android;
  }
  if (targetPlatform != null) {
    debugDefaultTargetPlatformOverride = targetPlatform;
  }
}

Example and Docs for matching Nav diffs per platform

Just a short note, I will be starting to work on a sample that takes Google's platform design example and reworks it to use this plugin.

It should help in as far getting to the point of adding more docs to this project.

I will put it on my Gightub account so I can link it in here when I have it polished.

WillPopScope wont work with PlatformScaffold

i tried using WillPopScope it didnt work.

what iam doing
page 1 => (pop 2) => page 2 => (pop 3) => page 3

what i happening
page 3 => (pop) => page 1

what i want
page 3 => (pop) => page 2

i was using APP > APP >Scaffold
correct way APP > scaffold > scaffold

bottomNavBar in Ios

i want to make bottom nav only in Ios but when only bottomTabBar in ios,it doesn't appear

PlatformIconButton not showing in IOS

I am using this widget in android everything works fine but in IOS ( Iphone X Similator) not showing button.

PlatformIconButton( onPressed: () => print('info pressed'), iosIcon: Icon( CupertinoIcons.info, color: Colors.red, ), androidIcon: Icon( Icons.info, color: Colors.black87, )),

Flutter (Channel master, v0.10.1-pre.40, on Mac OS X 10.13.6 17G65, locale tr-TR)
• Flutter version 0.10.1-pre.40 at /Users/macosx/flutter
• Framework revision 8e2ca93f52 (17 hours ago), 2018-10-12 21:07:55 -0700
• Engine revision 50c2e69daf
• Dart version 2.1.0-dev.7.0.flutter-b99bcfd309

Remove forced text transformation

So for some reason, PlatformText forcefully 'uppercases' any string inputted when used on Material mode.

I fixed this for my use case and I can submit a pull request if needed, but I would like to understand the rationale behind that decision.

appbar trailing widget off center

I can't believe I didn't think about googling for a package like this already existing.

Anyways, I am trying to implement a PlatformAppBar which has just a title and on the right it just has the word "Done" which is a PlatformButton.

PlatformAppBar(
                                          title:
                                              PlatformText("Picture"),
                                          leading: Container(),
                                          trailingActions: <Widget>[
                                            PlatformButton(
                                                onPressed: () {
                                                  Navigator.pop(context);
                                                },
                                                child: PlatformText('Done'))
                                          ])

image

I think the PlatformText is off center vertically (in relation to the title) because typically it would be expecting I believe an Icon of roughly a fixed size? Anyways, I tried adding a Container with padding to offset it from the bottom, but was unable to do that.

My apologies if I missed some other flag I was supposed to set.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.